Targeting dynamically created nested movieclips

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.

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