Flash EventListener Question
Hi Everyone,
If you had time for a Flash Event Lister question, I'd be most grateful.
a) Quick overview -
I'm creating an app for iPads, and using Flash CS6 and air.
I'm using simple code snippet Touchevents.
I have a Scene with 5 characters on the screen which when touched will play a short individual animation each.
Frames 1-100 are a loop animation which is also waiting for a touch event by a User (i.e. plays from frame 1 to frame 100 then goes back to frame 1).
Inside Frame 1 of the Actions layer, I have added 5 Touch EventListeners (just using standard Code Snippets) for each of the 5 characters that can be touched by the User.
I use a 'gotoandplay("LABELNAME");' within each EventListener, which will play each Character's unique animation, located later in the same timeline via 5 specific frame Label names. After each animation plays, I send it back to frame 1 again, to wait for another touch event on a Character.
e.g. Frame 1-100 main loop, Frame 101-150 is "Bob Character" Label, Frame 151-200 is "Jane Character" Label etc etc, with the last keyframe for each label ending with a "gotoandplay(1);" to send it back to the start.
B) The Goal -
I need to be able to press a Character onscreen, and while it's animation is playing, be able to touch another Character which will stop playing the current animation, and play the newly pressed animation instead.
C) The Issue -
The EventListeners I've set up work well, however I noticed that upon touching certain Characters onscreen, I can't touch a second Character immediately and play it's animation, as the first one is still playing until complete.
Still with me?
The plot thickens, because upon further investigation I found that according to its position along the timeline (using Labels for each Character's animation block), some animations are in fact able to 'interrupt' others, but others won't.
In summary - I found that a Character's Label/animation located along the timeline AFTER the current playing, CAN interrupt the current animation when touched. However trying to touch a Character whose Label/animation is located in the timeline BEFORE the current playing one, will NOT interrupt the current one playing.
I did a bit of a 'dodgy' test and sort of got around this by repeating the EventListener code for the Character Touchevents within the first frame of each new Label animation section. i.e. so it was listening again for Character touch events in each Label section.
This however seems like a lot of repeated Listener code throughout the timeline.
D) Thoughts -
This has me wondering if I have put the Eventlistener code in the proper location (i.e. inside Frame 1 of the Actions layer), and whether there is a 'global' location for the Scene that I can put them in so that they are always listening throughout the timeline, not matter at what point it is playing.
I really hope that makes sense.
Thanks so much, I appreciate your time.
Hanky
