Preloading assets
Hi,
I'm making a flash app for the web and have a lot of images and sound in it. I would like to preload these assets before the program loads so that the program runs smoothly without having to load assets on the spot
Here's my code:
function preLoader():void
{
for(var i:int = 1; i <= 6; i++)
{
for(var j:int = 1; j <= (this["array"+i][0].length)-1; j++)
{
snd1 = new Sound(new URLRequest(this["array"+i][0]
snd1.addEventListener(Event.COMPLETE, preLoadComplete);
image1.url = this["array" + i][1]
imageLoader1.load(image1);
imageLoader1.contentLoaderInfo.addEventListener(Event.COMPLETE, preLoadComplete);
}
}
}
function preLoadComplete(e:Event):void
{
count++;
if(count == totalAssetNo)
{
init();
}
}
All the paths for the images and sounds are stored in arrays.
The sounds preload fine but the images don't. The images only call the preLoadComplete function once in total not once each time something has loaded
Is this the correct way of preloading?
How can I correctly preload the images?
Cheers
Chris
