Event name collisions
Hello again ;]
I've come up yet with another problem:
[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert e3.timeline.events::PlaylistEvent@308d2f59 to e3.timeline.events.JavaScriptEvent.
Fault, routeEventToListener() at EventMap.as:166
Now, the interesting thing is that both classes PlaylistEvent
and JavaScriptEvent have an event named "SAVE":
public static const PlaylistEvent.SAVE = "SAVE";
public static const JavaScriptEvent.SAVE = "SAVE";
PlaylistEvent.SAVE is mapped to a command:
commandMap.mapEvent(PlaylistEvent.SAVE, SavePlaylistCommand, PlaylistEvent);
JavaScriptEvent.SAVE is mapped to a mediator's function:
eventMap.mapListener(eventDispatcher, JavaScriptEvent.SAVE, onSavePlaylist);
The event flow is as follows:
1. JavaScript executes save function on flash object
2. Save function has got a callBack function in JavaScriptService
which then dispatches system event JavaScriptEvent.SAVE
3. This event is cought by AppMediator which in turn samples some
data on its view and dispatches a different system event called
PlaylistEvent.SAVE.
4. The error occurs.
5. !!! Changing the string name of one of the events fixes the
problem which makes me think of event name collisions.
Any opinions on this? Thanks a lot for your time! ;]
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by derekdon on 01 Dec, 2009 01:03 AM
It's an event name collision from initial glance. Both constants have the same value of "SAVE".
I'm sure others may have an opinion on this, but I use the following naming convention to avoid this problem...
A similar approach may solve your problem.
Support Staff 2 Posted by Shaun Smith on 02 Dec, 2009 08:17 AM
It's a collision. You could use the naming technique suggested above, or preferably:
Use the 4th parameter of mapListener to ensure that your listeners only respond to events of the correct class.
Shaun Smith closed this discussion on 02 Dec, 2009 08:17 AM.