View Full Version : Unloaded external swf still playing
jslice390
11-30-2007, 05:48 PM
I am loading external .swfs into a movieclip. Before a new .swf is loaded I want to unload the one that is currently in the MovieClip.
Something like...
var mcLoader; //a Loader object
var movieHolder; //a MovieClip
function unloadExternalSWF() {
mcLoader.unload();
movieHolder.removeChild(mcLoader);
}
...this works for unloading mcLoader, but the problem is that I can still hear the audio from the external .swf (which I think means that the .swf isn't completely unloaded). The help in Adobe livedocs for Loader.unload isn't very helpful because I am not using a NetStream or Sound Object. My sound is on the maintimeline of the external .swf. How do I completely unload the .swf???
panel
11-30-2007, 06:50 PM
Catch is to remove all references to object
Event if you'll do object will be marked to remove by garbage collector and it'll be removed after sometime.
1. First be sure that all references to object are removed
2. Create some method allowing you stop all sound in particular movie
3. stopAllSounds
4. ulnoad
this way sound won't play and object will be removed after some time
Also look here
AS3: Resource Management (http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html)
jslice390
11-30-2007, 08:00 PM
How do I stop the sound when it is just streaming on the actual timeline of the external .swf?
panel
11-30-2007, 08:10 PM
use SoundTransform object of MovieClip (fi)
Here is example from language reference (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/)
The following example creates a sprite named container and adds a Loader object to its child list. The Loader object loads a SWF file. When the user clicks the link in the tf text field true, the mute() method sets the volume property of the soundTransform property of the container sprite:
import flash.display.Sprite;
import flash.display.Loader;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.media.SoundTransform;
var container:Sprite = new Sprite();
addChild(container);
var ldr:Loader = new Loader;
var urlReq:URLRequest = new URLRequest("SoundPlayer.swf");
ldr.load(urlReq);
container.addChild(ldr);
ldr.contentLoaderInfo.addEventListener(IOErrorEven t.IO_ERROR, urlNotFound);
var tf:TextField = new TextField();
tf.htmlText = "<a href = 'event:Mute'>Mute / Unmute</a>";
addChild(tf);
var mySoundTransform:SoundTransform = new SoundTransform();
mySoundTransform.volume = 1;
tf.addEventListener(MouseEvent.CLICK, mute);
function mute(event:MouseEvent):void {
if (mySoundTransform.volume == 0) {
mySoundTransform.volume = 1;
} else {
mySoundTransform.volume = 0;
}
container.soundTransform = mySoundTransform;
}
function urlNotFound(event:IOErrorEvent):void {
trace("The URL was not found.");
}
jslice390
11-30-2007, 09:21 PM
K, I figured out the real problem. The external .swfs that are loading in are loading other external .swfs--- It is the second external .swfs that continue to play. How can I stop them?
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.