# Accessing Embedded TextBoxes After Duplication

**URL:** <https://forum.kirupa.com/t/accessing-embedded-textboxes-after-duplication/268915>\
**Category:** flash\
**Created:** [August 20, 2008, 11:21am UTC](https://forum.kirupa.com/t/accessing-embedded-textboxes-after-duplication/268915 "2008-08-20T11:21:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimbobian](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jimbobian](https://forum.kirupa.com/u/jimbobian)\
**Post date:** [August 20, 2008, 11:21am UTC](https://forum.kirupa.com/t/accessing-embedded-textboxes-after-duplication/268915/1 "2008-08-20T11:21:14Z")

</div>

Hi, I am reasonably new to AS3 and would appreciate it if someone could help me solve this problem. I am trying to change the text in a dynamic text box after it has been duplicated and given a name.  
Heres how it works:  
The text box is in the library inside a movieclip.  
Using a loop this is then duplicated from the library (class: name\_score).  
It is then given a name and added to a movieclip already on the stage called drawSkeleton.  
After the loop another loop is used to get the movieclip holding the two textboxes, name\_txt and score\_txt.  
I then change the text using the code at the bottom which gives this error:  
Access of possibly undefined property score\_txt through…

Here is a simplified version of the code, without the loops:

```auto

[COLOR=black]var tempNS:DisplayObject=new name_score;[/COLOR]
[COLOR=black]tempNS.name="namescore3";[/COLOR]
[COLOR=black]drawSkeleton.addChild(tempNS);[/COLOR]
[COLOR=black]var currentDrawSection:DisplayObject = drawSkeleton.getChildByName("namescore3");[/COLOR]
[COLOR=black]currentDrawSection.score_txt.text="Hello World";[/COLOR]

```

When testing different versions of the code i tried this:

```auto
var tempNS:DisplayObject=new name_score;
[LEFT]tempNS.name="namescore3";
drawSkeleton.addChild(tempNS);
var currentDrawSection:DisplayObject = drawSkeleton.getChildByName("namescore3");
currentDrawSection.score_txt.x=1000;
//difference is here[/LEFT]

```

[LEFT]Which also failed, so then i tried this:[/LEFT]

```auto
var tempNS:DisplayObject=new name_score;
[LEFT]tempNS.name="namescore3";
drawSkeleton.addChild(tempNS);
var currentDrawSection:DisplayObject = drawSkeleton.getChildByName("namescore3");
currentDrawSection.x=1000
//difference is here[/LEFT]

```

Which worked. It obviously doesn’t like me trying to reach the text box inside the displayObject.

Like I said i’m pretty much a newbie to AS3 so any corrections to my code would be appreciated, and any help regards to my problem would be much appreciated.
