# addChild from within function

**URL:** <https://forum.kirupa.com/t/addchild-from-within-function/227799>\
**Category:** flash\
**Created:** [June 2, 2007, 10:39am UTC](https://forum.kirupa.com/t/addchild-from-within-function/227799 "2007-06-02T10:39:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![superbungalow](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@superbungalow](https://forum.kirupa.com/u/superbungalow)\
**Post date:** [June 2, 2007, 10:39am UTC](https://forum.kirupa.com/t/addchild-from-within-function/227799/1 "2007-06-02T10:39:16Z")

</div>

Hi,  
I am new to AS3, but in the past I have use the constructor class to draw a circle, using this code:

```auto
package {
    import flash.display.*;
    public class snake extends MovieClip {
        public var mc1:MovieClip = new MovieClip();
        public function snake() {
            mc1.graphics.lineStyle(1);
            mc1.graphics.beginFill(0xff0000);
            mc1.graphics.drawCircle(20,20,40);
            this.addChild(mc1);           

        }
}
}

```

and then in frame in the document class, “snake” ( I am trying to make a basic snake game at the moment, but haven’t got very far) and I found that that would draw the circle using the constructor.

Now I want to know, how would I call that through a non-constructor.I would like to do something like:  
var snakeone:snake: = new snake;  
snakeone.displaycircle();

in the actions of frame one, but I can’t seem to get that to do anything if I rename he function. What am I doing wrong? DO I need to set the document class as something different?

All help appreciated - I am really new at this.
