8 Replies Latest reply on Dec 16, 2008 9:36 AM by Newsgroup_User

    moviecliploader

    Level 7
      I am using a moviecliploader to load external swf files into a "container"
      swf.

      The files that I load contain their own timelines and functions etc.

      How can I be sure that the file has downloaded before the loaded clip starts
      calling its own functions?

      Many thanks


        • 1. Re: moviecliploader
          Level 7
          dave,

          >I am using a moviecliploader to load external swf files into a "container"
          > swf.

          Okay.

          > The files that I load contain their own timelines and functions etc.
          >
          > How can I be sure that the file has downloaded before the loaded clip
          > starts calling its own functions?

          You'll want to check out the MovieClipLoader class in the ActionScript
          2.0 Language Reference. Classes define objects -- they're effectively blue
          prints -- so if you want to know what the object can do, look up methods; if
          you want to know what characteristics are available to you, look up
          properties; to find out what the object can respond to (which is what you
          want here), look up events.

          In this case, you're after the MovieClipLoader.onLoadInit event (scroll
          down a bit in this blog entry):

          http://www.quip.net/blog/2006/flash/how-to-tell-when-external-swf-loaded


          David Stiller
          Co-author, Foundation Flash CS4 for Designers
          http://tinyurl.com/5j55cv
          "Luck is the residue of good design."


          • 2. Re: moviecliploader
            Level 7
            Thanks David

            I am using onLoadInit already, so that I can fade in the clip once it has
            loaded.

            My question is more to do with the loaded clip itself.

            For example the loaded clip may be a fairly large animation, which on frame
            1 has the script gotoAndPlay(20)

            If frame 20 has not loaded by the time frame 1 has loaded, does the script
            fail? Or does the whole movie get loaded before any scripts are executed?

            Hope that's a bit clearer.

            Thanks

            Dave


            "David Stiller" <stiller@quip-remove-.net> wrote in message
            news:gi62kh$5ic$1@forums.macromedia.com...
            > dave,
            >
            >>I am using a moviecliploader to load external swf files into a "container"
            >> swf.
            >
            > Okay.
            >
            >> The files that I load contain their own timelines and functions etc.
            >>
            >> How can I be sure that the file has downloaded before the loaded clip
            >> starts calling its own functions?
            >
            > You'll want to check out the MovieClipLoader class in the ActionScript
            > 2.0 Language Reference. Classes define objects -- they're effectively
            > blue prints -- so if you want to know what the object can do, look up
            > methods; if you want to know what characteristics are available to you,
            > look up properties; to find out what the object can respond to (which is
            > what you want here), look up events.
            >
            > In this case, you're after the MovieClipLoader.onLoadInit event (scroll
            > down a bit in this blog entry):
            >
            >
            > http://www.quip.net/blog/2006/flash/how-to-tell-when-external-swf-loaded
            >
            >
            > David Stiller
            > Co-author, Foundation Flash CS4 for Designers
            > http://tinyurl.com/5j55cv
            > "Luck is the residue of good design."
            >


            • 3. Re: moviecliploader
              Level 7
              dave,

              > I am using onLoadInit already, so that I can fade in the clip
              > once it has loaded.

              Cool. Gotcha.

              > My question is more to do with the loaded clip itself.
              >
              > For example the loaded clip may be a fairly large animation,
              > which on frame 1 has the script gotoAndPlay(20)

              Okay.

              > If frame 20 has not loaded by the time frame 1 has loaded,
              > does the script fail?

              Yes, because frame 20 "doesn't exist yet," as far as the SWF is
              concerned (or at least, as far as frame 1 is concerned). But the event
              we're discussing isn't dispatched until the external SWF has fully loaded --
              which means all of its frames are accounted for.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: moviecliploader
                Level 7
                Hi David

                Thanks again for your reply.

                So, if my loaded swf has its own timelines and functions and variables, what
                can I do to make sure it doesn't start executing code that cannot
                workbecause the swf hasn't fully loaded?

                Is there any specific technique to achieving this?



                "David Stiller" <stiller@quip-remove-.net> wrote in message
                news:gi654q$8ns$1@forums.macromedia.com...
                > dave,
                >
                >> I am using onLoadInit already, so that I can fade in the clip
                >> once it has loaded.
                >
                > Cool. Gotcha.
                >
                >> My question is more to do with the loaded clip itself.
                >>
                >> For example the loaded clip may be a fairly large animation,
                >> which on frame 1 has the script gotoAndPlay(20)
                >
                > Okay.
                >
                >> If frame 20 has not loaded by the time frame 1 has loaded,
                >> does the script fail?
                >
                > Yes, because frame 20 "doesn't exist yet," as far as the SWF is
                > concerned (or at least, as far as frame 1 is concerned). But the event
                > we're discussing isn't dispatched until the external SWF has fully
                > loaded -- which means all of its frames are accounted for.
                >
                >
                > David Stiller
                > Adobe Community Expert
                > Dev blog, http://www.quip.net/blog/
                > "Luck is the residue of good design."
                >


                • 5. Re: moviecliploader
                  Level 7
                  dave,

                  > So, if my loaded swf has its own timelines and functions and
                  > variables, what can I do to make sure it doesn't start
                  > executing code that cannot workbecause the swf hasn't fully
                  > loaded?

                  AHA! Man ... I'm sorry for completely missing the gist of your
                  question. I understand now (knock on wood!). Yes, you're right, when the
                  child SWF is requested, it will progressively download, just like the parent
                  SWF. Because of this, certain features -- like referencing frames that
                  haven't yet downloaded) might fail. If you have access to the child SWF's
                  source FLA, you could add a stop() action to frame 1 and wrap the remainder
                  of its frame 1 code into a custom function (say, init()), that you can then
                  execute from the parent SWF after loading is complete. Alternatively, you
                  could bump the child's frame 1 code into frame 2 -- while leaving the stop()
                  action in frame 1 -- and then instruct that SWF to play() after loading is
                  complete.

                  Does that make sense?


                  David Stiller
                  Adobe Community Expert
                  Dev blog, http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Re: moviecliploader
                    Level 7
                    Thanks David

                    I probably hadn't explained very well at first.

                    So I guess this could be quite a major problem if you were downloading 3rd
                    party content for whatever reason.

                    The content in this case is all mine so I can do as you have suggested.

                    Thanks again.

                    Dave


                    "David Stiller" <stiller@quip-remove-.net> wrote in message
                    news:gi8kaj$fve$1@forums.macromedia.com...
                    > dave,
                    >
                    >> So, if my loaded swf has its own timelines and functions and
                    >> variables, what can I do to make sure it doesn't start
                    >> executing code that cannot workbecause the swf hasn't fully
                    >> loaded?
                    >
                    > AHA! Man ... I'm sorry for completely missing the gist of your
                    > question. I understand now (knock on wood!). Yes, you're right, when the
                    > child SWF is requested, it will progressively download, just like the
                    > parent SWF. Because of this, certain features -- like referencing frames
                    > that haven't yet downloaded) might fail. If you have access to the child
                    > SWF's source FLA, you could add a stop() action to frame 1 and wrap the
                    > remainder of its frame 1 code into a custom function (say, init()), that
                    > you can then execute from the parent SWF after loading is complete.
                    > Alternatively, you could bump the child's frame 1 code into frame 2 --
                    > while leaving the stop() action in frame 1 -- and then instruct that SWF
                    > to play() after loading is complete.
                    >
                    > Does that make sense?
                    >
                    >
                    > David Stiller
                    > Adobe Community Expert
                    > Dev blog, http://www.quip.net/blog/
                    > "Luck is the residue of good design."
                    >


                    • 7. Re: moviecliploader
                      Level 7
                      dave,

                      > So I guess this could be quite a major problem if you were
                      > downloading 3rd party content for whatever reason.

                      True ... but there are often creative ways to hack around issues like
                      this. Ultimately, the responsibility lies with the content creator. If
                      someone makes a SWF to be given, sold, or otherwise shared as a 3rd party
                      widget, that widget should be "smart enough" to handle its own functionality
                      correctly. If the widget's first frame tells it to jump to another frame
                      that hasn't yet loaded, the problem you're describing holds true even when
                      the SWF is embedded directly into an HTML page. In other words, this isn't
                      a MovieClipLoader issue per se. Make sense?

                      Off the top of my head, I can imagine (this is theoretical) requesting
                      the child SWF via MovieClipLoader -- using the Sound class if necessary to
                      silence that container that loads it -- and, as soon as the child content is
                      fully loaded, dumping the container with MovieClip.unloadMovie(). By doing
                      this, you've stored the child SWF in the user's temporary Internet files.
                      When you request it again, on the heels of the first request, it should load
                      instantly (because it's already downloaded). Obviously, this hack assumes
                      that the user has room in his/her browser cache. Food for thought, anyway.
                      :)


                      David Stiller
                      Adobe Community Expert
                      Dev blog, http://www.quip.net/blog/
                      "Luck is the residue of good design."


                      • 8. Re: moviecliploader
                        Level 7
                        Yes, it's a fair point.

                        It would be nice if there were a "do nothing unitl loaded" flag but I guess
                        that is really not the point of flash.

                        The hack seems an interesting concept, but for now I think I wll put a
                        stop() in frame 1 of all loaded content and issue a play() when the
                        onloadinit is fired.

                        Thanks for your input.


                        "David Stiller" <stiller@quip-remove-.net> wrote in message
                        news:gi8o97$kv5$1@forums.macromedia.com...
                        > dave,
                        >
                        >> So I guess this could be quite a major problem if you were
                        >> downloading 3rd party content for whatever reason.
                        >
                        > True ... but there are often creative ways to hack around issues like
                        > this. Ultimately, the responsibility lies with the content creator. If
                        > someone makes a SWF to be given, sold, or otherwise shared as a 3rd party
                        > widget, that widget should be "smart enough" to handle its own
                        > functionality correctly. If the widget's first frame tells it to jump to
                        > another frame that hasn't yet loaded, the problem you're describing holds
                        > true even when the SWF is embedded directly into an HTML page. In other
                        > words, this isn't a MovieClipLoader issue per se. Make sense?
                        >
                        > Off the top of my head, I can imagine (this is theoretical) requesting
                        > the child SWF via MovieClipLoader -- using the Sound class if necessary to
                        > silence that container that loads it -- and, as soon as the child content
                        > is fully loaded, dumping the container with MovieClip.unloadMovie(). By
                        > doing this, you've stored the child SWF in the user's temporary Internet
                        > files. When you request it again, on the heels of the first request, it
                        > should load instantly (because it's already downloaded). Obviously, this
                        > hack assumes that the user has room in his/her browser cache. Food for
                        > thought, anyway. :)
                        >
                        >
                        > David Stiller
                        > Adobe Community Expert
                        > Dev blog, http://www.quip.net/blog/
                        > "Luck is the residue of good design."
                        >