# Problem with addChild in CS3

**URL:** https://forum.kirupa.com/t/problem-with-addchild-in-cs3/247924
**Category:** flash
**Created:** [January 1, 2008, 8:28pm UTC](https://forum.kirupa.com/t/problem-with-addchild-in-cs3/247924 "2008-01-01T20:28:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![MJMason](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MJMason](https://forum.kirupa.com/u/MJMason)
#### Post date: [January 1, 2008, 8:28pm UTC](https://forum.kirupa.com/t/problem-with-addchild-in-cs3/247924/1 "2008-01-01T20:28:23Z")

</div>

I’ve just started using AS3 after knowing a tiny bit of AS2, so sorry if this is a noobish question, anyway…

Basically when using a foreach loop on an XML document (from the kirupa example) I cannot use addChild when duplicating a movieclip (from another kirupa example).

I tried combining the XML book example with the BlueCircle duplication example because I want to achieve a similar thing with a box appearing, in this case, for each book and inside it the details of the book would put into a dynamic text box.

I probably haven’t explained it very well, but heres a snippet of the code I’m using and below that the error given. I’m guessing it’s because the XML uses addChild as well, so the two get confused, but I have no idea how to fix the problem.

```auto

var bookChildren:XMLList = bookInput.Book.children();
 
for each (var bookInfo:XML in bookChildren) {

function Main() {

var newCircle:BlueCircle = new BlueCircle();
newCircle.x = 50;
newCircle.y = 75;

this.addChild(newCircle);

}
Main();

trace(bookInfo);

}

}

```

```auto

XML Output
------------------------
TypeError: Error #1006: addChild is not a function.
    at MethodInfo-5()
    at test2_fla::MainTimeline/ParseStatus()
    at test2_fla::MainTimeline/LoadXML()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()

```

If anyone knows how to solve the problem I would be grateful.

Thanks in advance,

Michael
