Herdou uma classe de EventDispatcher no Flash, mas o evento personalizado não foi recebido
Tenho um evento personalizado que é despachado quando um controle deslizante é movido, mas não recebo nenhum evento da classe herdada do dispatcher que criei, enquanto seguia a mesma sintaxe da solução paraO meu evento personalizado em flash não dispara
Classe de eventos:
package {
import flash.events.Event;
public class CustomEvent extends Event
{
public static const ON_DISPATCHER_EVENT = "onDispatcherEvent";
public var value:Number;
public function CustomEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false):void
{
super(type, bubbles, cancelable);
}
}
}
Expedidor
package {
import flash.events.EventDispatcher;
import flash.events.Event;
public class CustomEventDispatcher extends EventDispatcher {
private var cEvent: CustomEvent;
public function CustomEventDispatcher() {
}
public function raiseEvent(_value:Number) {
cEvent = new CustomEvent(CustomEvent.ON_DISPATCHER_EVENT);
cEvent.value = _value;
dispatchEvent(cEvent);
}
}
}
Classe de teste:
package {
import flash.display.*;
import flash.net.*;
import flash.events.*;
import fl.events.SliderEvent;
import fl.controls.Slider;
public class TestCustomEvent extends MovieClip {
private var cEvent: CustomEvent;
public function TestCustomEvent() {
addEventListener( Event.ADDED_TO_STAGE, init);
}
public function init( e:Event ):void {
removeEventListener( Event.ADDED_TO_STAGE, init );
this.addEventListener(CustomEvent.ON_DISPATCHER_EVENT,OnDispatcherEvent);
slider.addEventListener(SliderEvent.CHANGE,OnSliderEventChange);
}
public function OnDispatcherEvent(event:CustomEvent): void {
trace(event.value);
}
public function OnSliderEventChange(event:SliderEvent) {
cEvent = new CustomEvent(CustomEvent.ON_DISPATCHER_EVENT);
cEvent.value = event.value;
dispatchEvent(cEvent);
trace("hello");
}
}
}