Looping through objects on the stage with Actionscript.

A couple of recent projects where I’ve needed to loop through each movieclip on the stage, and do something with it based on it’s instance name.The Flash file I was working with was going to be handed off to a designer who didn’t know AS3, and this was a handy way to pull info about each movieclip on the stage.


Basically, the loop looks at the instance name of each object on the stage to see which group of objects it belongs to. The advantage to this is that you don’t even need to know how many items are in each group, giving the designer the ability to add as many as they want, as long as they name them accordingly – myItem1, myItem2, myItem3, etc.

Submit a Comment