mardi 26 mai 2015

How to Load & Unload File SWF at same time

I'm an as3 newbie, i have one button as name tombol fuctioning to Loading External swf & going to Specific Frame by clicking buttons, this works fine.

import flash.events.MouseEvent;

tombol.addEventListener(MouseEvent.CLICK, tekan2);

function tekan2 (e:MouseEvent):void {

function loadSWF(swfURL){
    var myLoader:Loader = new Loader();
    var mySWF:URLRequest = new URLRequest(swfURL);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
    myLoader.load(mySWF);

}

function onCompleteHandler(loadEvent:Event){    
    addChild(loadEvent.currentTarget.content);
    loadEvent.currentTarget.content.gotoAndStop(swfFrame);
}

function onProgressHandler(myProgress:ProgressEvent){
    var percent:Number = Math.round(myProgress.bytesLoaded/myProgress.bytesTotal*100);
    trace(percent+"% loaded");
}

var swfFrame:Number=2;
loadSWF("2.swf");

}

This file save as 1.swf and loading file 2.swf go to frame 2, but file 1.swf still loading, so this script loading 2 file swfs(file 2.swf frame 2 loading with file 1.swf appears). How to file 1.swf can unloading same time when I click the button, so just file 2.swf frame appears on stage.

Aucun commentaire:

Enregistrer un commentaire