# AS3: how to reference a dynamic movieclip

**URL:** <https://forum.kirupa.com/t/as3-how-to-reference-a-dynamic-movieclip/295774>\
**Category:** flash\
**Created:** [September 4, 2009, 2:06am UTC](https://forum.kirupa.com/t/as3-how-to-reference-a-dynamic-movieclip/295774 "2009-09-04T02:06:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skankest](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@skankest](https://forum.kirupa.com/u/skankest)\
**Post date:** [September 4, 2009, 2:06am UTC](https://forum.kirupa.com/t/as3-how-to-reference-a-dynamic-movieclip/295774/1 "2009-09-04T02:06:51Z")

</div>

I have a number of identical movie clips that are generated in responce to an XML file. I’m trying to reference a specific one of these movieclips after a sound file stops playing. How do I call up that specific movieclip? How can dynamically created objects be referenced through the actionscript? Thanks in advance for any help!

Here is some of my simplified test code (without all the xml junk):

```php

for(var i = 0; i < 3; i++){
    var a = new test();
    addChild(a);
    a.x = 20 + (i * 150);
    a.addEventListener(MouseEvent.CLICK, doPlay);
    a.stop();
    
    a["snd"+i] = new Sound();        
    a["snd"+i].load(new URLRequest("creak128.mp3"));
    a.snd = a["snd"+i];
    a.addEventListener(MouseEvent.CLICK, playSound, false, 0, true);
    
}

function playSound(event:MouseEvent):void {
    var voice = event.currentTarget.snd.play();
    voice.addEventListener(Event.SOUND_COMPLETE, testing);

}

function doPlay(e:MouseEvent){
    e.currentTarget.play();
}

function testing(e:Event){
    trace("test works");
}

```
