AS2 loop through all the movie clips on the stage
Here is a quick way to get and set properties for all movie clips on the stage without having to know the instance names of each MovieClip.
for (var prop in this) {
if (this[prop] instanceof MovieClip) {
mc = this[prop];
trace ("test name: " + mc._name + " mc._x:" + mc._x + " a: " + mc._alpha);
}
}
admin
Tags: loop, properties, quick, root, stage

April 15th, 2010 at 9:38 am
This is a great little routine, but the related problem that’s killing me is:
I have a dozen or so movieclips that are all instances of a symbol.
An event occurs – like onRelease and and I’m now in the handler and I have no clue how to tell which movieclip instance got me there.
for example:
btn_01_mc.onRelease = buttonclicked;
btn_02_mc.onRelease = buttonclicked;
btn_03_mc.onRelease = buttonclicked;
All these buttons btn_XX__mc are instances of a movieclip symbol. How do I tell, in my buttonclicked function, which button did the clicking?
In my “really happy world” I would like to pass a parameter to my buttonclicked function from each button, but I can’t see how to do that either.
Any help greatly appreciated.
thanks
Doug
February 13th, 2012 at 7:46 pm
Try creating the “buttonclicked” as a method where you pass the MC that clicked it into the method. In Pseudo Code:
btn_01_mc.onRelease = buttonclicked(this);
function buttonclicked(theCallingMC:MovieClip)
{
this._name will= “the name of the MC that fired the method”;
}
Would that work for you?