I use custom events mostly when I have data to pass through the event which
doesn't fit nicely into some pre-defined one.  For instance, we have a
HighScoreEvent which has the number of points and the time it took to finish
the game.

Also, it is good practice to define your own Event subclass(es) to contain
the names of the events.  Otherwise you are left with this kind of thing:

addEventListener( "injury", onInjury );
dispatchEvent( new Event( "Injury" ));

And you have a bug caused by a spelling error.  If instead you do this:

addEventListener( InjuryEvent.INJURY, onInjury );
dispatchEvent( new InjuryEvent( InjuryEvent.lNJURY ));

The compiler will catch the spelling error for you.

Dave

On 12/18/08, Cor <[email protected]> wrote:
>
> Jason: This is all simplified, advanced coders would use some design
>
> patterns or frameworks to handle all this, but you get the idea.
>
>
> Maybe I am slow... or even dumb?
> But all those things I can do with normal events, I guess.
> So what I mean was an example of something you cannot do with normal event
> or what is specific case for using a custom event?
>
>
> Kind regards
>
> Cor
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to