繼承人可以使用什麼......這個加載所有圖片在後臺,當第一個被加載,所以你可以立即顯示它會給你通知時,所有加載...如果有很多的圖片我建議只加載下一個......不是所有的人不被內存豬..
var loadedImages:Vector.<DisplayObject> = new Vector.<DisplayObject>;
var imageUrls:Vector.<String> = new Vector.<String>;
// set your image urls, manually, from xml... whatever
imageUrls.push("http://www.mySite.com/image0.jpg");
imageUrls.push("http://www.mySite.com/image1.jpg");
imageUrls.push("http://www.mySite.com/image2.jpg");
// load all image sequentially
var curImageLoadingIndex:int=0;
loadNextImage();
/** loads each image sequentially via recursive calls */
function loadNextImage():void{
if (curImageLoadingIndex>=imageUrls.length){// done loading
allImagesLoaded()
}else{// load next one
var ldr:Loader=new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
ldr.load(new URLRequest(imageUrls[curImageLoadingIndex]));
function loaded(event:Event):void{
ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE,loaded);//remove listener to prevent memory leaks
loadedImages.push(ldr);//store loaded image for user whenever needed
if (curImageLoadingIndex==0)
firstImageReady();
curImageLoadingIndex++;//increment to load the next item
loadNextImage();
}
}
}
/** notificaltion when all the images have been loaded */
function allImagesLoaded():void{
// know all images are loaded here...
}
/** first image ready to use */
function firstImageReady():void{
var fistImage:DisplayObject = loadedImages[0];
// do something with your image here...
}
,如果你想使用的UILoader只是改變2號線在請求
var ldr:Loader=new UILoader();
ldr.addEventListener(Event.COMPLETE,loaded);
爲什麼不聲明一個裝載器數組並在官方化過程中加載所有文件? –
好的,但這兩個UILoader是在某些MC。我正在考慮一些使用JPG格式的容器,但我該怎麼做? –