4 Replies Latest reply on Sep 10, 2006 4:09 PM by Newsgroup_User

    onLoad question from a beginner

    b_rand
      Hi,

      I have the following code in a frame:

      lowerPanel_mc.onLoad = function() {
      y=1;
      trace("lowerPanel_mc onLoad event. y = " + y);
      }

      upperPanel_mc.onLoad = function() {
      y=5;
      trace("upperPanel_mc onLoad event. y = " + y);
      }

      Why does only the top function fire? If I switch the order and put the upperPanel.onLoad atop, then only it fires. What am I missing?

      Thanks, from a beginner.
        • 1. Re: onLoad question from a beginner
          aniebel Level 2
          Can you provide some more of your code for this movie? It might be that you are loading them into the same clip.
          • 2. Re: onLoad question from a beginner
            Level 7
            I believe you only use MovieClip.onLoad for MovieClip symbols in the library
            linked with an AS class.

            Here is the quote:
            "You use this handler only with movie clips for which you have a symbol in
            the library that is associated with a class. If you want an event handler to
            be invoked when a specific movie clip loads, you must use onClipEvent(load)
            or the MovieClipLoader class instead of this handlerl; for example, when you
            use MovieClip.loadMovie() to load a SWF file dynamically. Unlike
            MovieClip.onLoad, the other handlers are invoked when any movie clip
            loads." -- http://livedocs.macromedia.com/flash/8/main/00002494.html


            --
            Lon Hosford
            www.lonhosford.com
            Flash, Actionscript and Flash Media Server examples:
            http://flashexamples.hosfordusa.com
            May many happy bits flow your way!
            "b_rand" <webforumsuser@macromedia.com> wrote in message
            news:eddo68$lbj$1@forums.macromedia.com...
            > Hi,
            >
            > I have the following code in a frame:
            >
            > lowerPanel_mc.onLoad = function() {
            > y=1;
            > trace("lowerPanel_mc onLoad event. y = " + y);
            > }
            >
            > upperPanel_mc.onLoad = function() {
            > y=5;
            > trace("upperPanel_mc onLoad event. y = " + y);
            > }
            >
            > Why does only the top function fire? If I switch the order and put the
            > upperPanel.onLoad atop, then only it fires. What am I missing?
            >
            > Thanks, from a beginner.
            >


            • 3. Re: onLoad question from a beginner
              b_rand Level 1
              Hi,

              Thanks for the replies. Since I am a beginner, this is a bit challenging. I was using the onLoad instead of the onClipEven(load) since it appeared that the onClipEvent handler was only used within the object itself. I was trying to get as much of my code out on the main timeline as possible.

              Thanks for the replies - it is nice that you were willing the take the time to help.

              -Brian
              • 4. Re: onLoad question from a beginner
                Level 7
                Well perhaps the question is more why do you think you need onLoad?

                MovieClips that load external movies do have a timing problem. Here you want
                to use MovieClipLoader to handle the timing when the external swf is loaded
                and ready for referencing.

                MovieClips on the first frame where you use code in them can also have a
                timing problem. Here you can delay use of the MovieClip to the next frame.

                --
                Lon Hosford
                www.lonhosford.com
                Flash, Actionscript and Flash Media Server examples:
                http://flashexamples.hosfordusa.com
                May many happy bits flow your way!
                "b_rand" <webforumsuser@macromedia.com> wrote in message
                news:edhja8$3r1$1@forums.macromedia.com...
                > Hi,
                >
                > Thanks for the replies. Since I am a beginner, this is a bit challenging.
                > I
                > was using the onLoad instead of the onClipEven(load) since it appeared
                > that the
                > onClipEvent handler was only used within the object itself. I was trying
                > to get
                > as much of my code out on the main timeline as possible.
                >
                > Thanks for the replies - it is nice that you were willing the take the
                > time to
                > help.
                >
                > -Brian
                >