Take the 2-minute tour ×

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


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.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
add comment

Your Answer


