I'm trying to fire an event from sub class, I have 3 classes; EventHandler, MainClass, SubClass
EventHandler.as
public class EventHandler extends Event
{
public static const TEST_EVENT:String = "Test";
public function EventHandler($type:String, $params:Object, $bubbles:Boolean = false, $cancelable:Boolean = false)
{
super($type,$params, $bubbles, $cancelable);
this.params = $params;
}
public override function clone():Event
{
return new EventHandler(type, this.params, bubbles, cancelable);
}
}
MainClass.as
public function MainClass()
{
addEventListener(EventHandler.TEST_EVENT, testFunc);
}
private function testFunc(e:EventHandler){
trace("OK");
}
SubClass.as
private function CustomFunction(event:MouseEvent):void {
dispatchEvent(new EventHandler(EventHandler.TEST_EVENT,customObject));
}
I get VerifyError: Error #1063: flash.events::Event() What's wrong with my architect? Thanks!
Remove
$params
fromsuper($type,$params, $bubbles, $cancelable);
Like this: