# Targeting dynamically created nested movieclips

**URL:** <https://forum.kirupa.com/t/targeting-dynamically-created-nested-movieclips/305002>\
**Category:** flash\
**Created:** [February 17, 2010, 9:40pm UTC](https://forum.kirupa.com/t/targeting-dynamically-created-nested-movieclips/305002 "2010-02-17T21:40:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sluke](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sluke](https://forum.kirupa.com/u/sluke)\
**Post date:** [February 17, 2010, 9:40pm UTC](https://forum.kirupa.com/t/targeting-dynamically-created-nested-movieclips/305002/1 "2010-02-17T21:40:39Z")

</div>

Hi all,

got a bit of a problem I’ve moved into while working on a project.

I’m dynamically creating movieclips with dynamically created movieclips inside them and am having trouble with targeting them.

Below is a simplified example of what I’m trying to achieve, in the real file there are a lot more movieclips and I’m creating and naming them with a for loop.

This one is just one Sprite created inside another sprite. I can target the top level sprite named “testname”. However when i try target the nested MC it throws an error.

The bottom couple of traces are just test MCs I’ve made to make sure i got the syntax right, on targeting nested movieclips.

```php
var holder:Sprite = new test1(); 
holder.name = "testname"; 
this.addChild(holder); 

var holder2:Sprite = new test2(); 
holder2.name = "testname2"; 

holder.addChild(holder2); 

trace(getChildByName("testname").x); //this one traces fine 
trace(getChildByName("testname").getChildByName("testname2").x);//this throws up an error 

trace(testclip1.x); 
trace(testclip1.testclip2.x);  

```

I’m sure it’s just something simple I’m doing wrong but any help would be much appreciated,

Cheers
