# attachChild to stage from a class file

**URL:** <https://forum.kirupa.com/t/attachchild-to-stage-from-a-class-file/254493>\
**Category:** flash\
**Created:** [March 12, 2008, 5:53pm UTC](https://forum.kirupa.com/t/attachchild-to-stage-from-a-class-file/254493 "2008-03-12T17:53:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TCAtect](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@TCAtect](https://forum.kirupa.com/u/TCAtect)\
**Post date:** [March 12, 2008, 5:53pm UTC](https://forum.kirupa.com/t/attachchild-to-stage-from-a-class-file/254493/1 "2008-03-12T17:53:55Z")

</div>

I was trying to convert kirupa’s ADT Node class into AS 3, when I ran into a problem. In the Node constructor, Kirupa used attachMovie, which as we now know is obsolete in AS3. However, when I used addChild(); nothing really happens (no movieclip is attached to stage), or, if I try to refer to a display object on stage (displayObject.object2.addChild(movieClipClass);), it returns with an error along to lines of “displayObject is undefined” or something. Additionally, when I try to refer to the stage (stage.displayObject.object2…etc), it returns another error (something about null).

As I am writing this thread at a friend’s place, I do not have the swf/fla/as file on hand. However, when I get back home, I will post the source code ASAP. For now, I simply need to know if it is possible to “see” an object on the stage from within a class. I.E. in the constructor function, can I say “stage.object1.x=100” or something)

Thank you,  
TCAtect

EDIT: Yes, I meant addChild 😊. The old AS 2 haunts me…
