AS3 :: Get all Children MovieClips

It is easy in ActionScript 3 to get all the chlidren instances of a MovieClip.  Take a look at the AS3 code below for help. 
for (var i:uint = 0; i < mcMain.numChildren; i++){ 
    txtOutput.htmlText += 'name:' + mcMain.getChildAt(i).name;
    txtOutput.htmlText += '\t type:' + typeof (mcMain.getChildAt(i));
    txtOutput.htmlText += '\t' + mcMain.getChildAt(i);
    txtOutput.htmlText += "";
}

The above code uses a for loop, to loop through the total number of children in mcMain.  mcMain.getChildAt(i) will get the reference to the child instance.  By tacking .name to the end of mcMain.getChildAt(i) you can get the name of the child object.

 

download source

 del.icio.us  Stumbleupon  Technorati  Digg 

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments

Leave a comment

Submitted comments will be subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.