Thursday, September 1, 2011

Child loop

If you have a movie clip on the stage with multiple objects inside of it:
(for example a square movie clip named boxContainer with smaller squares inside)


for (var i:int = 0; i<boxContainer_mc.numChildren; i++) {
var thechild = boxContainer_mc.getChildAt(i);
trace (;

 If the parent has a property, for example a boolean property that you want to change,
sometimes it can't find which parent you are referring to so you have to tell it like this:
 nameParent(boxContainer_mc.getChildAt(i)).myProperty = true; 

In this example boxContainer holds a bunch of boxes. Boxes has a boolen property (inside the file):
public var myProperty:Boolean = false;  
In the main file:
Boxes(boxContainer_mc.getChildAt(i)).myPropery = true; 

No comments:

Post a Comment