javascript - JSFL for...in loop doesn't seem to work -
javascript - JSFL for...in loop doesn't seem to work -
i'm writing script in jsfl flash cs5, , i'm trying list of layers off main timeline. i'm getting timeline, looping through for...in loop, objects i'm getting seem undefined. here's test code made:
alert(fl.getdocumentdom().gettimeline().layers[0].name); //returns "text1" for(layer in fl.getdocumentdom().gettimeline().layers) { alert(layer.name); //returns "undefined" }
so, jsfl not back upwards for...in? that's kinda odd, since seems it's javascript engine.
whoooh there. jsfl not javascript engine, bizarro world javascript can remarkably unpredictable. don't believe me? not sure if still case, seek fl.getdocumentdom().selection.push(<obj>)
. didn't work, did: var s = fl.getdocumentdom().selection; s.push(<obj>) fl.getdocumentdom().selection = s
.
that said, syntax off:
var layers = fl.getdocumentdom().gettimeline().layers; // include 'var' it's taste for(var layer in layers) { // for... in iterates keys, have lookup alert(layers[layer].name); }
as aside, you're improve off iterating through arrays numeric indexes, clearer , faster.
javascript flash for-loop jsfl
Comments
Post a Comment