跟踪事件流程

时间:2011-06-27 15:28:59

标签: actionscript-3 events event-bubbling

我正在调度一个来自类实例(“class c”)

的气泡的自定义事件
dispatchEvent(new ScoreEvent(ScoreEvent.SCORE, amount, true));

这是我的ScoreEvent课程:

package
{

import flash.events.Event;

public class ScoreEvent extends Event
{
    public static const SCORE:String = "score";
    public static const FAIL:String = "fail";

    public var amount:int;

    public function ScoreEvent(type:String, amount:int = 0, bubbles:Boolean=true, cancelable:Boolean=false) {
        super(type, bubbles, cancelable);
        this.amount = amount;
        trace(type, amount, bubbles);
    }

    override public function clone():Event {
        return new ScoreEvent(type, amount, bubbles, cancelable);
    }

}

}

“class c”嵌套在“class a”里面的“class b”里面。在“class a”中,我设置了一个监听器来监听事件:

stage.addEventListener(ScoreEvent.SCORE, onScore, false, 0, true);

private function onScore(e:ScoreEvent):void {
trace(e)
}

然而,虽然我(试过?)将冒泡设置为true,但我的事件似乎没有到达舞台活动?

0 个答案:

没有答案