PDA

View Full Version : Problem with closing loader, sound keeps playing.



Gordonski
July 15th, 2009, 07:20 AM
Hi there,

Since im still a beginner im running into this problem: I have a main movie wich loades video from external swf files through the loader. If i unload the loader and remove the child the sound keeps playing from the previous swf. Below my code and i know it aint pretty so any help would be very nice ! thx in advance ! :write:


this.stage.scaleMode = "noScale";

var clips:Array = ["scene01.swf", "scene02.swf", "scene03.swf", "scene04.swf", "scene05.swf", "scene06.swf"];
var index:int = 0;

var request:URLRequest = new URLRequest(clips[index]);
var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Progress Event.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);

function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
trace("Loading: "+percentLoaded+"%");
}

function loadComplete(event:Event):void {
trace("Complete");
}

loader.load(request);

function holderAdd(){
//loader.close();
loader.unload();
holder.addChild(loader);
}
holderAdd();

function sceneOne():void {
holderAdd();
loader.load( new URLRequest(clips[0]) );
}

function sceneTwo():void {
holderAdd();
loader.load( new URLRequest(clips[1]) );
}

function sceneThree():void {
holderAdd();
loader.load( new URLRequest(clips[2]) );
}

function sceneFour():void {
holderAdd();
loader.load( new URLRequest(clips[3]) );
}

function sceneFive():void {
holderAdd();
loader.load( new URLRequest(clips[4]) );
}

function sceneSix():void {
holderAdd();
loader.load( new URLRequest(clips[5]) );
}

function speelScene01(evt:MouseEvent):void {
holder.removeChild(loader);
trace("loader removed");
sceneOne();
holder.navBar.btnDroomhuis.removeEventListener(Mou seEvent.CLICK, speelScene01);
}

function speelScene02(evt:MouseEvent):void {
holder.removeChild(loader);
sceneTwo();
}

function speelScene03(evt:MouseEvent):void {
holder.removeChild(loader);
sceneThree();
}

function speelScene04(evt:MouseEvent):void {
holder.removeChild(loader);
sceneFour();
}

function speelScene05(evt:MouseEvent):void {
holder.removeChild(loader);
sceneFive();
}

function speelScene06(evt:MouseEvent):void {
holder.removeChild(loader);
sceneSix();
}

werehunt
July 15th, 2009, 07:46 AM
Steps to be followed before Unloading any SWF

1. Tell any loaded .swf child assets to disable themselves.
2. Stop any sounds from playing.
3. Stop the main timeline, if it is currently playing.
4. Stop any movie clips that are currently playing.
5. Close any connected network objects, such as instances of Loader, URLLoader, Socket, XMLSocket, LocalConnection, 6. NetConnections, and NetStream.
7. Release all references to cameras and microphones.
8. Remove all event listeners
9. Stop any currently running intervals (via clearInterval()).
10. Stop any Timer objects (via the Timer class’s instance method stop()).
11. Dispose all subobjects
12. Release all references to external objects
In future Flash Player 10, does these by calling the Loader class’s new method unloadAndStop().

Gordonski
July 15th, 2009, 07:51 AM
steps to be followed before unloading any swf

1. Tell any loaded .swf child assets to disable themselves.
2. Stop any sounds from playing.
3. Stop the main timeline, if it is currently playing.
4. Stop any movie clips that are currently playing.
5. Close any connected network objects, such as instances of loader, urlloader, socket, xmlsocket, localconnection, 6. Netconnections, and netstream.
7. Release all references to cameras and microphones.
8. Remove all event listeners
9. Stop any currently running intervals (via clearinterval()).
10. Stop any timer objects (via the timer class’s instance method stop()).
11. Dispose all subobjects
12. Release all references to external objects
in future flash player 10, does these by calling the loader class’s new method unloadandstop().

amazing :d ! thx !