完成事件

时间:2015-08-05 11:16:41

标签: actionscript-3 events

我试图在另一个swf1中加载swf2并显示swf2的加载进度。执行此操作后,当swf2完全下载时,ProgressEvent.PROGRESS将触发。请建议我改变的地方。 我这样做了

import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.IOErrorEvent; 

var myLoader = new Loader(); 
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError); 

myLoader.load(new URLRequest("swf/Set1.swf"));

function onProgress(evt:ProgressEvent):void {
var nPercent:Number = Math.round((evt.bytesLoaded / evt.bytesTotal) * 100);    
temp.text = nPercent.toString() + "%";
} 
function onComplete(evt:Event):void {
myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);  
addChild(myLoader);
} 
function onIOError(evt:IOErrorEvent):void {
trace("IOError loading SWF");
}

0 个答案:

没有答案