Hi,
I’m curious, I’ve been testing how to search for specific movieclip on stage and came a cross the typeof operator.
So my test was creating ten movieclips on stage and then trace them with a for loop, like this:
var count:Number = 10;
for (var i = 0; i<count; i++) {
attachMovie("myMC", "my"+i+"_mc", this.getNextHighestDepth());
var my_mc:MovieClip = _root["my"+i+"_mc"];
my_mc._x = 5+40*i;
my_mc._y = 5;
my_mc.id = i;
my_mc.nmb_txt.text = i;
}
my_btn.onRelease = function() {
for (var prop in _root) {
if (typeof _root[prop] == "movieclip") {
myNmb_txt.text += " "+_root[prop].id;
}
}
};
When I run this I get as expected ten movieclips on the stage, but when the typeof loop runs the output is:
“9 9 8 7 6 5 4 3 2 1 0”.
So my question is, where did the duplicate “9” come from?
Regards, Ollu