AS3 OOP: Button not showing
I am learning AS3 OOP and trying to do some simple stuff, here I am just
trying to add a button onto the stage and handle the click event.
Here is my simple code:
package
{
import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class External extends MovieClip
{
private var counter:Number;
public var HitButtonA:RedButton;
public function External() // constructor
{
HitButtonA= new RedButton();
HitButtonA.x = 40;
HitButtonA.y = 65;
addChild(HitButtonA);
setupListeners();
counter=0;
}
public function setupListeners()
{ trace("bbbb");
HitButtonA.addEventListener(MouseEvent.CLICK, hitButtA);
}
public function hitButtA(e:MouseEvent)
{
//display.text=String(++counter);
trace("aaaaa");
}
}
}
Unfortunately, it does not even add the button onto the stage, no error or
anything... any idea whats wrong?
No comments:
Post a Comment