开发者

how can I unload a swf with AS3?

开发者 https://www.devze.com 2022-12-11 09:13 出处:网络
Any body can help on how I can do to unload a swf before I load the next one? var mLoader:Loader = new Loader();

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, onC开发者_如何学CompleteHandler);
    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);
}


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


mLoader.unload()


Try using unloadAndStop() instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号