Hi, I’m creating a portfolio for my self.
I’m going to show a bunch of images in a slideshow.
Since everybody hate waiting for things to load, I thought it would be a good idea to load all the images in the background while the user is clicking on other things.
- user enters page
– design and menues are loaded
— the page is showed to the user
---- images used in other parts of the flash-site is loading “behind the scenes”.
When the user finally open the slideshow, he/she don’t have to wait for the images to load.
This is my code:
function downloadImages(i:uint = 0) {
trace("- Downloading portfolio images");
loading();
function loading() {
_loader = new Loader();
_loader.load(new URLRequest("http://urlstosite"+_imageURLS[ i]));
_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadingProgress);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, storeImage);
}
function storeImage(e:Event):void {
_image.push(_loader);
i++
if (i < _imageURLS.length()) {
trace("image nr:"+i+" downloaded");
loading();
} else {
trace(" - Images are downloaded");
}
}
}
In this case _image is an array. I’ve also tried to make it a sprite and used the addChild.
In both tries I get Error #1006: value is not a function.