[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:
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):
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?