• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Problem on display loader

New Here ,
Jul 27, 2011 Jul 27, 2011

Copy link to clipboard

Copied

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.PROGRES 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();

     }

}

TOPICS
ActionScript

Views

328

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 27, 2011 Jul 27, 2011

Copy link to clipboard

Copied

Try Loader.unloadAndStop()

...

swfLoader1.unloadAndStop();

nextScene();

...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 27, 2011 Jul 27, 2011

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines