This content has been marked as final.
Show 4 replies
-
1. Re: Extending EventDispatcher with dynamic event types
Jamesabth Jan 22, 2008 12:30 AM (in response to sneakyimp)You can dispatch an event from the class with dispatchEvent(new Event(params)); and then listen to myInstance.addEventListener("name", func); -
2. Re: Extending EventDispatcher with dynamic event types
sneakyimp Jan 22, 2008 1:41 AM (in response to sneakyimp)i don't understand what you mean?
what goes in params?
what object does myInstance refer to?
and how does this help answer my question? -
3. Re: Extending EventDispatcher with dynamic event types
Damon Edwards Jan 22, 2008 7:01 AM (in response to sneakyimp)Look up EventDispatcher in the help docs. It gives a great explanation there. -
4. Extending EventDispatcher with dynamic event types
sneakyimp Jan 22, 2008 11:39 AM (in response to Damon Edwards)I have looked it up here:
Actionscript 3.0 Language Reference
and it just says that the first arg to 'addEventListener' is "The type of event" with no further explanation at all.
I have read this:
Flash Quick Starts: Programming With Actionscript 3.0: Event handling
It doesn't help much either. It tells me I need the appropriate event object which makes me wonder DO I NEED MY OWN CLASS? For that first ard to addEventListener, it merely says "Substitute the appropriate constant". Given that I want to use dynamic types (i think so anyway) that is not helpful information either. Every single example on that page uses a class constant for event type.
It links to this which says "First, the name of the specific event you want to respond to. Once again, each event is affiliated with a specific class, and that class will have a special value predefined for each event--sort of like the event's own unique name, which you should use for the first parameter." Still no useful detail about what that arg does and the insistence on constants.
The quick start page also has a link title "Handling Events" in Programming ActionScript 3.0 but it links to some documentation titled "Working with XML". The only discussion of events in that 10 or so pages is because some user posted a comment.
I have read this entire article which is more helpful than anything in the flash docs but still doesn't answer all my questions which (AGAIN) are:
1) What is the real function of the first argument to addEventListener? I have not seen a clear explanation anywhere.
2) Do I need to write my own Event class?
3) What about dynamic event types that are defined at runtime? Are there any pitfalls or risks that arise from using a string instead of a predefined constant as the first param to addEventListener() ?
Please stop telling me to read the documentation. I've been reading it for days.

