# Difficulty with constructor function

**URL:** <https://forum.kirupa.com/t/difficulty-with-constructor-function/283354>\
**Category:** flash\
**Created:** [March 5, 2009, 7:14am UTC](https://forum.kirupa.com/t/difficulty-with-constructor-function/283354 "2009-03-05T07:14:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![battlebison](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@battlebison](https://forum.kirupa.com/u/battlebison)\
**Post date:** [March 5, 2009, 7:14am UTC](https://forum.kirupa.com/t/difficulty-with-constructor-function/283354/1 "2009-03-05T07:14:02Z")

</div>

[SIZE=1]Disclaimer: I’m new to AS3.[/SIZE]  
So I’m trying to get the constructor function to run when I add a child to the stage. I had it working a minute ago in a separate .fla file, but can’t figure it out in this one. Here, I’m just making it place explosions where I click. The movie clip shows, but no function! What am I doing wrong?

On stage:

```auto
stage.addEventListener(MouseEvent.CLICK, exploder);
function exploder(event:MouseEvent):void{
    var explosion1:Explosion1 = new Explosion1();
    explosion1.x = mouseX - (explosion1.width / 2)
    explosion1.y = mouseY - (explosion1.height / 2)
    trace("boom?")
    addChild(explosion1);    
}

```

In Explosion1.as (in same folder as .fla):

```auto
package{
    import flash.display.MovieClip;
    import flash.events.*; //for future use
    public class Explosion1 extends MovieClip
    {
        public function Explosion1()
        {
            trace("boom!")
        }
    }
}

```

Shouldn’t that public function be triggered when the addChild command is processed?
