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 the handler being, again, dispatch(event). Finally, component3 listens for the event coming out of component2. What I am trying to do is similar to the concept of "re-throwing" exceptions (and for similar reasons). The difference is that re-dispatching does not seem to work in AS3 (Flash 10). In IE, nothing happens, and in FF3 there is an exception saying that the type cast failed while trying to coerce the Event type to my CustomEvent while calling the handler in component3. Tracing code in the debugger shows that by the time component3 is called, the event is, indeed, a generic one, with all my custom stuff lost. Is this supposed to be the case?
相关问题
- garbage collection best practices
- Stop child process when parent process stops
- Fire resize event once not based on timing
- How to load flex swf from flash?
- C# CS0079 Event Handling Compile Errors
相关文章
- What does it means in C# : using -= operator by ev
- How are custom broadcast events implemented in Jav
- Programming a touch screen application with SWING
- How many pixels are scrolled on a website with a m
- Difference Between RoutedEventHandler and EventHan
- Wait for function till user stops typing
- WPF- validation error event doesn't fire
- Button onclick doesn't fire after onchange inp
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:
more see:http://casario.blogs.com/mmworld/2006/08/the_clone_metho.html