views:

134

answers:

3

Any body can help on how I can do to unload a swf before I load the next one?

var mLoader:Loader = new Loader();

function loadSWF(e:Event):void {

    var imageId:Array = e.target.name.split("_");
    var targetId:int = imageId[0];
    var caption:int = imageId[1];

    txt = arrayText[caption];
    dynText1.text = "";
    dynText1.text = arrayText[caption];
    dynText1.setTextFormat(textFormatMain);

    var swf:String = "swf/" + xmlList[targetId].image[caption].@swf;

    if (mLoader.content != null)
    {   
     swfLoad.swfArea.mLoader.unload();
     swfLoad.swfArea.mLoader.load(null);
    }

    mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);

    mLoader.load(new URLRequest(swf));
}

//-------------------------------------------------------------------------//

function onCompleteHandler(loadEvent:Event):void
{
        swfLoad.swfArea.addChild(loadEvent.currentTarget.content);
     TweenLite.to(swfLoad, 0.5, {alpha:1});
}

function onProgressHandler(mProgress:ProgressEvent):void
{
    //var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
    //trace(percent);
}
A: 
mLoader.unload()
Lieven Cardoen
tried that and won't do anything at all
Ole Media
Strange. Had similar problems in the past, but that was with Flash 8 and I really can't remember anymore what the solution was. If I were you I would try an example explained in http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#unload() and go from there. Is all of your code in the fla? Or are you using classes?
Lieven Cardoen
A: 

You'll hopefully be targeting Flash Player 10 so you can use unloadAndStop(), but .unload should get you part of the way there.

http://www.gskinner.com/blog/archives/2008/07/additional_info.html

Typeoneerror
A: 

Try using unloadAndStop() instead.

andkjaer