0

我在 Robotlegs 中创建了一个调解器,它的相关视图将调度两种不同类型的事件。当中介捕获事件时,它只会简单地分派事件。我遇到的问题是第一个事件被完美地重新调度,但第二个事件没有被调度。

但是,如果我手动为第二个事件分配不同的处理程序,则该事件会被正确捕获。

下面是相关代码:

public class MyMediator extends Mediator
{
    [Inject]
    public var view:MyView;

    public override function onRegister():void
    {
        super.onRegister();

        addViewListener( SomeEventTypeA.COOL_EVENT, dispatch, SomeEventTypeA ); // This event is dispatched correctly
        addViewListener( SomeEventTypeB.STUCK, dispatch, SomeEventTypeB );  // This one is not correctly dispatched

        //A twist, if I uncomment the following code, the event is captured by its handler
        //addViewListener( SomeEventTypeB.STUCK, view_stuck, SomeEventTypeB );
    }

    private function view_stuck( event:SomeEventTypeB ):void
    {
        //ah ha, this is called correctly if the above relevant line is uncommented
    }
}
4

1 回答 1

0

找到原因:

该事件需要具有适当的克隆方法才能正确重新调度。见相关链接:

http://knowledge.robotlegs.org/kb/application-architecture/why-doesnt-my-event-trigger-the-command-it-is-mapped-to

于 2012-12-23T13:27:15.757 回答