Skip navigation
xxxheeroxxx
Currently Being Moderated

Problem on display loader

Jul 27, 2011 3:40 AM

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);

swfLoader1.load(swfUrl1);

movieMC.addChild(swfLoader1);

 

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.PROGRE S S, swfLoadedHandler1);

     sceneLoaderMC.visible = false;

     mc1 = MovieClip(swfLoader1.content);

     mc1.gotoAndPlay(1);

}

 

function onEnterFrame1(e: Event):void{

 

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

 

          mc1.removeEventListener(Event.ENTER_FRAME, onEnterFrame1);

          mc1 = null;

          nextScene();

     }

}

 
Replies
  • Currently Being Moderated
    Jul 27, 2011 4:01 AM   in reply to xxxheeroxxx

    Try Loader.unloadAndStop()

    ...
    swfLoader1.unloadAndStop();
    nextScene();
    ...
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2011 4:27 AM   in reply to xxxheeroxxx

     

    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

    loader.unloadAndStop();

    }

     

     

     

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points