This content has been marked as final. Show 3 replies
There are a few reasons but one is it helps to keep your scripts all in one location... on the main timeline... so you (and anyone else who works on the FLA) can easily track down code for troubleshooting or editing.
David Stiller has a good blog entry on the topic: Check it out here.
I wouldn't say ON a keyframe, that sounds like on a frame. I believe you mean the difference between on(clip event) which is placed on an instance of a movieclip or myClip.onClipEvent which is code placed on a timeline/frame.
Thanks aniebel for that link. David Stiller is a genius and really hit the point.
For me code consolidation is certainly the biggest reason for it as well. But from that you start to see ways to put your code together that are just better and lead naturally into OOP style and concepts.
avonova – it is totally worth learning how to do it this way. In AS3 you will no longer be able to use any of the on(clipEvent) style coding. (Still supported in CS3 if you publish to earlier versions of AS2 or 1.)
thanx for your i/p folks, greatly appreciated - but its the placement of event handler definitions in general i'm trying to clarify.
aniebel thanx for that David Stiller link.
Rothrock your AS3 point noted, will keep it in mind when that comes around for me.
i'm going with the following:-
an event handler defined ON a keyframe is triggered when the playhead reaches that frame;
an event handler defined WITHIN a keyframe is triggered due to a user interacting with an object instance regardless of where the playhead is.
it'll do me for now as a distinction.