views:

34

answers:

1

Hi guys.. I have a question about the event dispatch. I am trying to write the code for youtube player and find the following link..

http://www.codingcolor.com/as3/as3-youtube-chromless-api/

He has many dispatchEvent call similar like this:

 dispatchEvent(new YouTubeEvent(YouTubeEvent.ON_IOERROR,event));

For my understanding, custom event usually dispatch like below:

 dispatchEvent(new Event(YouTubeEvent.ON_IOERROR));

I am not sure why he can add ,event after On_IOERROR. I appreciate if anyone would help me about this. Thanks.

+3  A: 

Without knowing the API, my guess is that YouTubeEvent is intended to be consumed by the API clients, rather than the native flash events (such as IoErrorEvent, in this case). So, the code dispatches an instance of YouTubeEvent instead of IoErrorEvent. YouTubeEvent most likely also gives you access to the original event (through a variable or property) in case you need access to that data.

Regarding your question "I am not sure why he can add ,event after On_IOERROR": YouTubeEvent must be a custom event (a class defined by you or someone else that extends Event). So its constructor can take any parameters its author defined.

Juan Pablo Califano