2 Replies Latest reply on May 26, 2007 5:55 AM by Newsgroup_User

    Why use onClipEvent(load)?

    OrangeHaze
      Hello, I am curious if there is any benefit to putting code inside the onClipEvent(load) event handler instead of simply putting any code you want run on the very first frame of the movieclip? It seems that both yield the same results; however, Adobe/Macromedia seems to discourage putting code directly on MovieClips and Buttons, so I'm actually curious why the onClipEvent handler has not been deprecated.
        • 1. Re: Why use onClipEvent(load)?
          Rothrock Level 5
          The onClipEvent() handlers were largely surpassed when Flash 6 came out in 2001. Unfortunately many tutorials, etc. were made with the old style and never updated. So many folks come to Flash and some how learn those and never change – despite the, to me at least, obvious benefits of the MovieClip.onClipEvent approach.

          David Stiller has written a good article about it:

          http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent

          And, they have been depreciated. If you publish for AS3, then you won't be able to put code on instances – only in external .as files and timeline/frames.
          • 2. Re: Why use onClipEvent(load)?
            Level 7
            The load event is instance based vs code on the timeline (of that movie
            clip) being symbol based. If you have 2 copies of that symbol on your
            main timeline, code within the symbol's timeline will always be the same for
            both of those copies. Using the onClipEvent(load) event handler you can
            change the code for each instance individually because you can easily write
            two different load handlers for both.

            As Rothrock said, though, there isn't much point to using these kinds of
            commands since Flash 6 and dynamic events, onClipEvent style events are
            pretty dead in the water. Most people only use them now because they're
            used to an older style of coding. onClipEvent(load) is actually an
            exception in that there is no (direct) comparable dynamic event handler. An
            onLoad exists, but only works in certain situations. Instead, you would
            just write code directly within the parent timeline containing the movie
            clip.

            "OrangeHaze" <webforumsuser@macromedia.com> wrote in message
            news:f38668$q91$1@forums.macromedia.com...
            > Hello, I am curious if there is any benefit to putting code inside the
            > onClipEvent(load) event handler instead of simply putting any code you
            > want run
            > on the very first frame of the movieclip? It seems that both yield the
            > same
            > results; however, Adobe/Macromedia seems to discourage putting code
            > directly on
            > MovieClips and Buttons, so I'm actually curious why the onClipEvent
            > handler has
            > not been deprecated.
            >