XML.prototype.ignoreWhite=true _global.trace = ASnative(100, 4) //flow namespace _global.flow = {} //flow.xrender namespace _global.flow.xrender = {} _global.flow.xrender.debug = function(p,x){ var t //debug timer t = new Date().getTime() _global.flow.xrender.render(p,x) //debug timer t = new Date().getTime() - t trace('Xrender('+p+') completed in '+t+'ms') } // flow.xrender.render function // // recursive handling of XML and handler execution _global.flow.xrender.render = function(p,x,s){ if (x == undefined) return if (typeof(x) == 'string') x = new XML(x) x = x.firstChild if (s==undefined){ trace('set s to Array') s=[] } //Loop Through XML while (x != null){ //x.nodeType is an Element if (x.nodeType == 1) { //trace(' handler:'+x.nodeName+ ' path:'+p +' xml:'+x) _global.flow.xrender.handler[x.nodeName.toLowerCase()](p,x,s.concat([x.nodeName.toLowerCase()])) } x = x.nextSibling; } trace(s) } // flow.xrender.handler namespace // holds handler functions for XRENDER // a = _global.flow.xrender.handler={} //movieclip handler // a.mc = a['movieclip'] = function(p,x,s){ trace('_global.flow.xrender.handler.movieClip('+p+','+x+',['+s.join('|')+'])') //define vars var attr,mc,a //grab the attributes attr = x.attributes //filter attribute vals if(attr.depth == undefined) attr.depth = p.getNextHighestDepth() if(attr.name == undefined) attr.name = 'instance'+attr.depth // no id > createEmptyMovieClip if(attr.id == undefined){ mc = p.createEmptyMovieClip(attr.name,attr.depth) // id > attachMovie }else{ mc = p.attachMovie(attr.id, attr.name,attr.depth) } // instance creation failure avoid further execution if(mc==undefined) return //add attributes to the created clip for(a in attr){ if(a=='id')continue if(a=='depth')continue if(a=='name')continue mc[a] = attr[a] } _global.flow.xrender.render(mc,x,s) } //button handler // a.button = a['mx:controls:button'] = a['mx:button']= function(p,x,s){ trace('_global.flow.xrender.handler.mx:Button('+p+','+x+',['+s.join('|')+'])') //define vars var attr,mc,a //grab the attributes attr = x.attributes //filter attribute vals if(attr.depth == undefined) attr.depth = p.getNextHighestDepth() if(attr.name == undefined) attr.name = 'instance'+attr.depth mc = p.attachMovie("Button", attr.name, attr.depth) // instance creation failure avoid further execution if(mc==undefined) return for(a in attr){ if(a=='id')continue if(a=='depth')continue if(a=='name')continue if(a=='width')continue if(a=='height')continue if(a=='_width')continue if(a=='_height')continue mc[a] = attr[a] } if(attr.width == undefined) attr.width = mc.width if(attr.height == undefined) attr.height = mc.height if(Number(attr.width) == NaN) attr.width = mc.width if(Number(attr.height)== NaN) attr.height = mc.height mc.setSize(Number(attr.width),Number(attr.height)) _global.flow.xrender.render(mc,x,s) } //number handler // a.n = a['number'] = function(p,x,s){ trace('_global.flow.xrender.handler.number('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = new Number(attr.value) _global.flow.xrender.render(p[attr.name],x,s) } //string handler // a.s = a['string'] = function(p,x,s){ trace('_global.flow.xrender.handler.string('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = new String(attr.value) _global.flow.xrender.render(p[attr.name],x,s) } //boolean handler // a.b = a['boolean'] = function(p,x,s){ trace('_global.flow.xrender.handler.boolean('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes //restrict boolean values if(attr.value=='1' or attr.value=='0' or attr.value=='true' or attr.value=='false') p[attr.name] = new Boolean(attr.value) _global.flow.xrender.render(p[attr.name],x,s) } //function handler // a.f = a['function'] = function(p,x,s){ trace('_global.flow.xrender.handler.function('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = eval(attr.value) _global.flow.xrender.render(p[attr.name],x,s) } //array handler // a.a = a['array'] = function(p,x,s){ trace('_global.flow.xrender.handler.array('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = new Array() _global.flow.xrender.render(p[attr.name],x,s) } //object handler // a.o = a['object'] = function(p,x,s){ trace('_global.flow.xrender.handler.object('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = new Object() _global.flow.xrender.render(p[attr.name],x,s) } //reference handler // a.r = a['reference'] = function(p,x,s){ trace('_global.flow.xrender.handler.reference('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = eval(attr.value) } //date handler // a.d = a['date'] = function(p,x,s){ trace('_global.flow.xrender.handler.date('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = new Date() if(attr.year!=undefined && Number(attr.year)!=NaN) p[attr.name].setFullYear(Number(attr.year)) if(attr.month!=undefined && Number(attr.month)!=NaN) p[attr.name].setMonth(Number(attr.month)-1) if(attr.day!=undefined && Number(attr.day)!=NaN) p[attr.name].setDate(Number(attr.day)) if(attr.hour!=undefined && Number(attr.hour)!=NaN) p[attr.name].setHour(Number(attr.hour)) if(attr.minute!=undefined && Number(attr.minute)!=NaN) p[attr.name].setMinute(Number(attr.minute)) if(attr.second!=undefined && Number(attr.second)!=NaN) p[attr.name].setSecond(Number(attr.second)) if(attr.millisecond!=undefined && Number(attr.millisecond)!=NaN) p[attr.name].setMillisecond(Number(attr.millisecond)) if(attr.time!=undefined && Number(attr.time)!=NaN) p[attr.name].setTime(Number(attr.time)) _global.flow.xrender.render(p[attr.name],x,s) } //color handler // a.c = a['color'] = function(p,x,s){ trace('_global.flow.xrender.handler.color('+p+','+x+',['+s.join('|')+'])') //define vars var attr //grab the attributes attr = x.attributes p[attr.name] = new Color(eval(attr.target)) if(attr.rgb != undefined) p[attr.name].setRGB(attr.rgb) _global.flow.xrender.render(p[attr.name],x,s) } delete a