我正在使用Flash Build Image控件使用.source属性从外部加载图像,我想为每个图像的加载过程添加百分比动画,只是想知道我该怎么做?
答案 0 :(得分:1)
Image docs显示Image是SWFLoader,而SWFLoader有ProgressEvent.PROGRESS
个事件。
答案 1 :(得分:1)
private var loader:Loader;
private var request:URLRequest;
function loadImage() {
loader=new Loader();
request=new URLRequest(image_path);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
loader.load(request);
}
function loadProgress(e:ProgressEvent):void {
// The following variable holds the ratio of loaded bytes to total bytes
// Use it to increase size, show percentage, etc
var pct:Number = loader.contentLoaderInfo.bytesLoaded/loader.contentLoaderInfo.bytesTotal;
}
function loadComplete(e:Event):void {
// Add all events that are to be fired after loading of the image
}
调用loadImage函数开始加载图像。