Monday 15 June 2015

actionscript 3 - Type cast error in dispatchEvent -


I have three sections: A, B, C Class A transmits an event, square B handles it and then it will send it. However, I found this strange type of casting error in the transmission function of B, which looks like this:

  Public function handler (Event: some avent): zero {removeEventListeners (); DispatchEvent (event); }  

If I change it to the following, I do not get any errors:

  Public function handlers (Event: SomeEvent): Zero {removeEventListeners (); Var newEvent: SomeEvent = event.clone (); // Send a clone of yourself Event (new event); }  

Can anyone help me on this? Thank you.

Are you using a custom event? If you are, you need to define the clone method. When you "redirect", Event Flash automatically clones the event and sends the clone. This is the reason why you change your code to event .clone () This works. So, in a nutshell, your second implementation is right.

If you do not want to write that extra bit code, you should apply the clone method. Documents of EventDispatcher.dispatchEvent () show this:


No comments:

Post a Comment