9 Replies Latest reply on Sep 16, 2010 5:19 PM by kglad

    External swf question...

    celebritymusic Level 1

      Hey all

       

      I found this code for loading external swfs and playing them in succession.

       

      It works when I use the external swfs that come with the code, but not when I try to use any other external swfs.

       

      I can't figure out why - does anything seem obvious (the clip swfs are here http://www.flashandmath.com/intermediate/externalclips/clip0.swf http://www.flashandmath.com/intermediate/externalclips/clip1.swf http://www.flashandmath.com/intermediate/externalclips/clip2.swf ):

       


      // Array of external clips to use. Variable index refers to next clip to be displayed.
      var clips:Array = ["clip0.swf", "clip1.swf", "clip2.swf"];
      var index:int = 0;

       

      // Stuff to load swf files
      var thisLoader:Loader = new Loader();
      thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);
      //loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataOnLoad);

       

      var thisMC:MovieClip = new MovieClip();
      stage.addChild(thisMC);            // Add empty MC initially so the nextClip function can be generic

       

      // Removes old MC and gets the next one, waiting until when it has initialized beore adding it to the stage
      function nextClip():void {
          thisLoader.load(new URLRequest(clips[index]));
      }

       

      // Tell AS that the loaded file is a movie clip and add it to the stage.
      function doneLoading(e:Event):void {

       

      stage.removeChild(thisMC);

       

      thisMC = MovieClip(thisLoader.content);

       

      thisLoader.unload();

       

      thisMC.addEventListener(Event.ENTER_FRAME, runOnce);

       

      stage.addChild(thisMC);

       

      thisMC.gotoAndPlay(1);

       

      }

       

      // When thisMC has finished, play the next clip.

       

      function runOnce(e:Event):void {

       

      if (thisMC.currentFrame == thisMC.totalFrames) {

       

      thisMC.removeEventListener(Event.ENTER_FRAME, runOnce);

       

      index = (index + 1)%(clips.length);

       

      nextClip();

       

      }

       

      }

       

       

       

      // Call the nextClip function initially to get the ball rolling

       

      nextClip();

       

       

       

       

       

      Thanks for taking a look guys.

       

      Shaun

        • 1. Re: External swf question...
          kglad Adobe Community Professional & MVP

          do you use same named swfs (eg, clip0.swf etc)?

          • 2. Re: External swf question...
            celebritymusic Level 1

            Yep - I even tried renaming my new swfs clip0.swf

            , clip1.swf etc

            • 3. Re: External swf question...
              Ganesh_Palwe Level 3

              How are the SWFs you are trying to load were published? Are they created using AS1 or AS2?

              • 4. Re: External swf question...
                kglad Adobe Community Professional & MVP

                what do you mean you "even tried..."?  that is required unless you change the array names.

                 

                so, do your array strings match your file names?  if yes, and the files are all in the same directory the swfs will load.

                 

                what problem do you see?

                1 person found this helpful
                • 5. Re: External swf question...
                  celebritymusic Level 1

                  One of the swfs returns:

                   

                  TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@26f9b3a1 to flash.display.MovieClip.
                      at alt2_fla::MainTimeline/doneLoading()

                   

                  (I'm pretty sure it's an AS3 swf)

                   

                  The other, which I had just built using AS3, returns:

                   

                  TypeError: Error #1009: Cannot access a property or method of a null object reference.
                      at fl.rsl::RSLPreloader/loadContent()
                      at _001_fla::MainTimeline__Preloader__/frame2()
                  Error: Error #2099: The loading object is not sufficiently loaded to provide this information.
                      at flash.display::LoaderInfo/get width()
                      at loader_animation_fla::MainTimeline/frame1()
                  Error: Error #2099: The loading object is not sufficiently loaded to provide this information.
                      at flash.display::LoaderInfo/get width()
                      at loader_animation_fla::MainTimeline/frame1()
                  TypeError: Error #1009: Cannot access a property or method of a null object reference.
                      at fl.rsl::RSLPreloader/loadContent()
                      at _001_fla::MainTimeline__Preloader__/frame2()

                  • 6. Re: External swf question...
                    kglad Adobe Community Professional & MVP

                    the first error is caused by trying to load a non-as3 swf.

                     

                    the 2nd you can better understand by clicking file/publish settings/flash and ticking "permit debugging".  retest.  the problematic line of code will be in your error message.

                    1 person found this helpful
                    • 7. Re: External swf question...
                      celebritymusic Level 1

                      Ahh...

                       

                      Debugging isn't showing me a line number.

                       

                      Is there a way to turn off the included preloader that's in Flash CS5?  The word preloader is all through the error messages.

                       

                      Cheers

                      • 8. Re: External swf question...
                        celebritymusic Level 1

                        OK... it's something to do with tlf text...

                         

                        I made a new external swf project file, and just put some plain old classic text into it.  The exported swf loads fine into the main project file.

                         

                        However, as soon as I make it tlf text, I get all those preloader errors come up.

                         

                        I'd like to have the freedom of putting whatever I like in the external file, so how do I get around this preloader problem, or what do I have to do to my external files to make them ok to load into the main project swf?

                         

                        Cheers

                         

                        Shaun

                        • 9. Re: External swf question...
                          kglad Adobe Community Professional & MVP

                          if you don't have a reason to use tlf text, don't use it.  there are some bugs that have no work-around.

                           

                          if you want to play with the tlf preloader, click file/publish settings/flash/as 3/settings/library and change your default linkage.