I am new to AS3.
For graphical representation I use fla file as a resource. I work in Flash Builder 4.6 to code.
I try to create own class Panel which contains the click event. But event doesn't work when I test the move!
When I move the event handler (buttonClick) and event listener to main class (test) and apply the event to the card object (for example), all works fine.
What is wrong with my code?
My main class of application:
package
{
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
import ui.Panel;
public class test extends Sprite
{
var card:Panel;
public function test()
{
card = new Panel();
addChild(card);
}
}
}
The Panel class:
package ui
{
import flash.display.MovieClip;
import flash.events.*;
public class Panel extends MovieClip
{
var back:PanelBack;
var button:PanelButton;
public function Panel()
{
super();
back = new PanelBack();
button = new PanelButton();
addChild(back);
addChild(button);
button.addEventListener(MouseEvent.CLICK,buttonClick);
}
private function buttonClick(event:MouseEvent):void
{
trace("Hello");
}
}
}