Using the numChildren property to loop through a container's child objects


show more Using the numChildren property to loop through a container's child objects provides you with in-depth training on Developer. Taught by Todd Perkins as part of the ActionScript 3.0 in Flash Professional CS5 Essential Training show less
please wait ...

Using the numChildren property to loop through a container's child objects

Sometimes you may want to perform an action on each child object in a display object container. Using arrays and for loops, it's a simple process. Let's take these trashcans on Stage here. Notice that they're in a movie clip called container. If I double-click container, I can enter its Timeline. Notice that none of these trashcans have an instance name, but I still want to align them to the zero position, vertically. Let's take a look at how that is possible.

This is a trick that's going to work, whether or not objects have an instance name. Let's select the first keyframe of the actions layer, and open up the Actions panel. I'll start by creating a for Loop. Remember, it's for, and then parentheses, and curly braces. Inside of the for Loop, type var space i, colon uint; - remember that's a positive integer, equals zero, semicolon, space, i, less than, and space.

We'll stop there for just a second. Now here, we want to run a loop for each child inside ...

Using the numChildren property to loop through a container's child objects
Video duration: 3m 17s 7h 8m Beginner Updated May 23, 2012

Viewers:

Using the numChildren property to loop through a container's child objects provides you with in-depth training on Developer. Taught by Todd Perkins as part of the ActionScript 3.0 in Flash Professional CS5 Essential Training

please wait ...