heresこれはバックグラウンドですべてのイメージを読み込み、最初に読み込まれたときに通知して、すぐに表示したり、すべてが読み込まれたときに通知したりします。私は、次のいずれかをロード示唆画像...それらのすべてではないが...
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);
あなたはローダの配列を宣言し、inaticization内のすべてのファイルをロードしませんか? –
でも、これらの2つのUILoadersは何かMCにあります。私はthouse JPGといくつかのコンテナについて考えていますが、どうすればいいですか? –