還有就是我的自定義事件爲什麼沒有跟蹤輸出?我的Flash自定義事件不會觸發
自定義事件類值屬性:與剛剛滑塊
package {
import flash.events.Event;
public class CustomEvent extends Event
{
public static const ON_CUSTOM_EVENT:String = "onCustomEvent";
public var value:Number;
public function CustomEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false):void
{
super(type, bubbles, cancelable);
}
}
}
Test類重新調度滑塊事件:
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_CUSTOM_EVENT,OnCustomEvent);
slider.addEventListener(SliderEvent.CHANGE,OnSliderEventChange);
}
public function OnCustomEvent(event:CustomEvent): void {
trace(event.value);
}
public function OnSliderEventChange(event:SliderEvent) {
cEvent = new CustomEvent("OnCustomEvent");
cEvent.value = event.value;
dispatchEvent(cEvent);
trace("hello");
}
}
}
這將是更容易與調度程序的代碼來診斷。 'OnSliderEventChange'觸發了嗎? – Kodiak 2011-04-07 14:22:15
在代碼窗口中向下滾動。起初我也沒有注意到。 – jhocking 2011-04-07 14:50:06
好的,那麼:是否觸發了「OnSliderEventChange」? – Kodiak 2011-04-07 15:48:38