2009-11-16 72 views
0

任何機構可以幫助我如何才能在卸載swf之前加載下一個swf?如何使用AS3卸載swf?

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][email protected]; 

    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); 
} 
+0

通過卸載,您試圖從內存中刪除SWF文件? – 2009-11-16 22:04:47

+0

卸載是什麼意思? – 2009-11-16 22:08:04

+0

卸載含義擺脫當前在舞臺上的swf文件加載一個新的 – 2009-11-16 22:35:38

回答

0
mLoader.unload() 
+0

試過,並且根本不會做任何事 – 2009-11-16 22:15:14

+0

奇怪。過去有類似的問題,但那是在Flash 8上,我真的不記得解決方案是什麼。如果我是你,我會嘗試在http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#unload()中解釋的例子,然後從那裏開始。你所有的代碼都在fla?還是你在使用類? – 2009-11-17 08:51:50

0

嘗試使用unloadAndStop()代替。