3 Replies Latest reply on May 10, 2007 5:15 PM by avonova

    event handler method definitions - whats the difference

    avonova
      hi folks,

      i'm a newbie and have just started trying to get my head around flash 8 actionscript.

      is anyone able to advise me what is the distinction/difference/subtlety between defining an event handler method ON a keyframe as compared to defining an event handler method WITHIN a keyframe.

      evidently this is a keypoint to understand so if i don't get this clear i expect it'll cause me grief later.

      thanx for your response.

      regards,

      avonova
        • 1. Re: event handler method definitions - whats the difference
          aniebel Level 2
          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.
          • 2. Re: event handler method definitions - whats the difference
            Rothrock Level 5
            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.)
            • 3. Re: event handler method definitions - whats the difference
              avonova Level 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.

              ciao!