# Accessing multiple movie clips with loop and getChildByName

**URL:** <https://forum.kirupa.com/t/accessing-multiple-movie-clips-with-loop-and-getchildbyname/315775>\
**Category:** Uncategorized\
**Created:** [November 3, 2010, 6:52pm UTC](https://forum.kirupa.com/t/accessing-multiple-movie-clips-with-loop-and-getchildbyname/315775 "2010-11-03T18:52:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![atarijake](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@atarijake](https://forum.kirupa.com/u/atarijake)\
**Post date:** [November 3, 2010, 6:52pm UTC](https://forum.kirupa.com/t/accessing-multiple-movie-clips-with-loop-and-getchildbyname/315775/1 "2010-11-03T18:52:30Z")

</div>

Hey, quick question about accessing movie clips on stage in AS3.

All i really want to do is be able to affect multiple movieclips at once with event listeners and greensock tweens.

The first snag I hit was that I couldn’t create references to movie clips using the old [] Associative array referencing method. Maybe I still can with AS3, but I couldn’t get it to work…

So I found another technique using getChildByName that returns a reference to a movie clips and allows me to store that reference in a variable.

However, the movie clip I’m trying to affect with an event listener resides inside of another movie clips, so to build the address (aka, root.mc1.m2.mc3) to the mc I want to get to is proving to be difficult. (I’m very new to AS3…)

I thought the trace(target1\_mc.target2\_mc.name); at the bottom of the following code would output the name of target2\_mc but it doesn’t…

Any idea what I’ve done wrong?

Thanks!

```
        var i:uint=0;
        for (i=0; i &lt; sidebarLength; i++) {

            var target1_mc:MovieClip;
            target1_mc = MovieClip(getChildByName("btn_0"+(i+1)+"_highlight"));

            var target2_mc:MovieClip;
            target2_mc = MovieClip(target1_mc.getChildByName("highlight_hotspot_mc"));

            trace(target1_mc.name);
            trace(target2_mc.name);
            trace(target1_mc.target2_mc.name);
                        
        }
```
