2 Replies Latest reply on Jul 27, 2011 4:01 AM by kennethkawamoto2

    Problem on display loader


      I got this code in Scene 1, 2 & 3 only differ on its suffixes like swfLoader1, swfLoader2 and so on.


      It seems that when I click on next button the previous swf still playing because of the sound embeded on the timeline of the swf.


      I know there is something missing in this code.

      I already got the current mc = null before the nextScene().

      I guess its in the swfLoader1 variable but I'm totally no idea on it.


      import flash.display.Loader;

      import flash.net.URLRequest;

      import flash.events.ProgressEvent;

      import flash.events.Event;

      import flash.display.MovieClip;

      import flash.events.MouseEvent;


      var mc1: MovieClip;


      var swfLoader1: Loader = new Loader();

      var swfUrl1: URLRequest = new URLRequest("scene1.swf");


      swfLoader1.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, swfProgressHandler1);

      swfLoader1.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadedHandler1);




      function swfProgressHandler1(e: ProgressEvent):void{

           var loadPercent: Number = e.bytesLoaded / e.bytesTotal;

           sceneLoaderMC.sceneLoaderBarMC.scaleX = loadPercent;

           sceneLoaderMC.sceneLoaderPercent.text = (Math.ceil(loadPercent * 100)).toString() + "%";



      function swfLoadedHandler1(e: Event):void{

           swfLoader1.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoadedHandler1);

           swfLoader1.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRES S, swfLoadedHandler1);

           sceneLoaderMC.visible = false;

           mc1 = MovieClip(swfLoader1.content);




      function onEnterFrame1(e: Event):void{


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


                mc1.removeEventListener(Event.ENTER_FRAME, onEnterFrame1);

                mc1 = null;




        • 1. Re: Problem on display loader
          kennethkawamoto2 Level 5

          Try Loader.unloadAndStop()

          1 person found this helpful
          • 2. Re: Problem on display loader
            relaxatraja Level 5


            var loader:Loader = new Loader();

            loader.load ( new URLRequest ( "content.swf" ) );

            addChild ( loader );

            stage.addEventListener ( MouseEvent.CLICK, unloadSWF );

            function unloadSWF ( e:MouseEvent ):void


            // Unload the SWF file with automatic object deactivation

            // All deactivation is handled automatically






            According to the AS3 current documentation, after calling Loader.unloadAndStop, the following happens:




                * Sounds are stopped.


                * Stage event listeners are removed.


                * Event listeners for enterFrame, frameConstructed, exitFrame, activate and deactivate are removed.


                * Timers are stopped.


                * Camera and Microphone instances are detached

                * Movie clips are stopped.