Hi, You say this is a compiler error. Do you actually mean a runtime error?
Maybe I'm misunderstanding what your doing (a code extract would help), but this looks right to me. You're dispatching an event of TypeAEvent, the base class and your listening for that event. Remember, you listen for event names, not specific event class instances. If you listen for an event with a specific name, the handler will be called without taking the type into account. You're then trying to coerce that TypeAEvent into its subclass, TybeBEvent. The event isn't of TypeBEvent and so you get the runtime error. Had you been dispatching a TypeBEvent, and then coerced that to a TypeAEvent, then things would work. Makes senes? Alistair -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of mosesoak Sent: 25 May 2007 17:50 To: [email protected] Subject: [flexcoders] Compiler issue with event bubbling I made a post to the adobe AS3.0 forum regarding the following problem which came up using the Flex compiler. Please view the full post for more details. "Event bubbling causes a compiler error when it should not." - High up in the display list, a listener has been added for TypeBEvent which extends TypeAEvent. - Lower in the display list, a different object dispatches a TypeAEvent, and sets bubbling to true (and possibly, cancellable to false). - A Type Coercion error (#1034) results! The listener receives the bubbled event which is of the same type as the base class of the handler event type. The event object "cannot be converted" to the TypeBEvent it is receiving. "...the player breaks and does not provide any clue as to where, it only indicates the dispatching class as a culprit. Even short of fixing the problem, improving the error message so that the receiving event handler is clearly implicated would be a start. "Again I am of the opinion that this compiler error should not take place at all because the top class subscribed specifically to the subclassed event type." Full post: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm? forumid=60&catid=587&threadid=1271034&enterthread=y -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links

