# How to addChild() to Stage From a Packaged Class?

**URL:** <https://forum.kirupa.com/t/how-to-addchild-to-stage-from-a-packaged-class/279642>\
**Category:** flash\
**Created:** [January 16, 2009, 9:45pm UTC](https://forum.kirupa.com/t/how-to-addchild-to-stage-from-a-packaged-class/279642 "2009-01-16T21:45:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sstecken](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sstecken](https://forum.kirupa.com/u/sstecken)\
**Post date:** [January 16, 2009, 9:45pm UTC](https://forum.kirupa.com/t/how-to-addchild-to-stage-from-a-packaged-class/279642/1 "2009-01-16T21:45:09Z")

</div>

I have a public class as a package.

Upon creating a new class object, the constructor attempts to add a sprite to the stage. I receive the error:  
“1180: Call to a possibly undefined method addChild.”

The code snippit reads as such:

private var sprite:Sprite = new Sprite();  
private var dot:Shape;  
public function Scope(initialName:String = “”, initialSpriteX:Number = 0, initialSpriteY:Number = 100):void {  
name = initialName;  
sprite.x = initialSpriteX;  
sprite.y = initialSpriteY;  
addChild(sprite);  
dot = new Shape();  
sprite.addChild(dot);  
}

My guess is that now that the coding is in a package, addChild() needs to be preceded with something such as flash.display.Stage.addChild(); however I do not know what.

Commenting out addChild() causes my code to compile fine, however I’m just seeing a blank screen instead of an oscilloscope (there is far more code to get the scope to cycle, but is irrelevant to this post).
