Re-dispatching event in FLEX

后端 未结 2 670
眼角桃花
眼角桃花 2021-01-02 01:38

In a FLEX app, I am trying to \"re-dispatch\" a custom event. I.e. component1 does dispatchEvnet(event), component2 registers a handler for the event, the only function of t

相关标签:
2条回答
  • 2021-01-02 02:19

    The problem you are experiencing is caused by not overriding the clone() event in your custom event.

    When events are redispatched, they are cloned and modified. If you don't override clone() you get the base implementation of clone(), which returns an Event. Because Event cannot be cast to your custom event type, a runtime error is thrown.

    From the documentation:

    When creating your own custom Event class, you must override the inherited Event.clone() method in order for it to duplicate the properties of your custom class. If you do not set all the properties that you add in your event subclass, those properties will not have the correct values when listeners handle the redispatched event.

    0 讨论(0)
  • 2021-01-02 02:39

    more see:http://casario.blogs.com/mmworld/2006/08/the_clone_metho.html

    0 讨论(0)
提交回复
热议问题