0
我正在使用Flash Build Image控件從外部使用.source屬性加載圖像,我想爲每個圖像的加載過程添加百分比動畫,只是想知道我該怎麼做?如何做圖像加載動畫?
我正在使用Flash Build Image控件從外部使用.source屬性加載圖像,我想爲每個圖像的加載過程添加百分比動畫,只是想知道我該怎麼做?如何做圖像加載動畫?
Image docs顯示Image是SWFLoader,而SWFLoader有ProgressEvent.PROGRESS
事件。
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函數開始加載圖像。