-
Senior Member
Preloading external image3s
I have successfully done a tutorial at Kirupa about preloaders and transitions.
http://www.kirupa.com/developer/mx/p...transition.htm
My problem is that I have a swf file that loads external jpegs and I cannot get the tutorial to work correctly with this swf. It only preloads the the swf and not the external content that this swf is calling.
Here is the code that I have on the main timeline of the home.swf
PHP Code:
var imgList:Array = new Array();
imgList[0] = "images/image00.jpg";
imgList[1] = "images/image01.jpg";
imgList[2] = "images/image02.jpg";
imgList[3] = "images/image03.jpg";
imgList[4] = "images/image04.jpg";
function chooseTheString() {
randomPic = random(imgList.length-0);
pics.loadMovie(imgList[randomPic]);
}
chooseTheString();
_quality = "best";
stop();
The rest of my swf files preload correctly but I just can't get it to preload this one correctly at all. I would appreciate any help that you can give.
"My boss sits and watches TV in a hot dog suit and I think he might be a moron."
-
All 1s and 0s
Hi,
Flash won't preload images just becuase you have put references to them into an array. Images are only loaded when a 'loadMovie' command is passed. To get this to work, you will have to add to your preloader by loading in each movie one by one, which will be best achieved by making use of the MovieClipLoader class.
Do you want me to create some code for you to show you how this would work?
"If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton
-
Senior Member
That would be helpful, if you could.
"My boss sits and watches TV in a hot dog suit and I think he might be a moron."
-
Senior Member
"My boss sits and watches TV in a hot dog suit and I think he might be a moron."
-
All 1s and 0s
Sorry, I'll try and get this done by tomorrow at the latest!
"If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton
-
All 1s and 0s
Hi,
I'm really sorry - I was positive I replied to this message. I even made a .fla for it which I subsequently deleted. Oh well, here's a better example anyway. Paste this code onto frame 1:
code:
//Our array containing our image data;
var imgArray:Array = new Array();
imgArray[0] = "http://freestockphotos.com/ANIMALS/BighornSheep4.jpg";
imgArray[1] = "http://freestockphotos.com/ANIMALS/DeerWinter.jpeg";
imgArray[2] = "http://freestockphotos.com/ANIMALS/Bullsnake22.jpeg";
//etc...
//Create an index variable we can use to check how many images have loaded;
var imagesLoaded:Number = 0;
//Create a MovieClipLoader
var mcl:MovieClipLoader = new MovieClipLoader;
//Create a listener object for the MovieClipLoader to catch events (like when the loading is finished);
var listener:Object = new Object();
//When loading starts, make a trace;
listener.onLoadStart = function(target:MovieClip) {
trace("Image "+target+" is loading");
}
//When loading finishes, imcrement imageLoaded;
listener.onLoadComplete = function(target:MovieClip) {
trace("An image has loaded");
//Make invisible;
target._visible = false;
//Increment imageLoaded;
imagesLoaded++
//If we have no images left to load:
if (imagesLoaded == imgArray.length) {
trace("All images loaded");
}
}
//Attach the listener to the MovieClipLoader;
mcl.addListener(listener);
//Loop through the array loading all images;
for (image in imgArray) {
var mc:MovieClip = this.createEmptyMovieClip("image"+image, this.getNextHighestDepth());
mcl.loadClip(imgArray[image], mc);
}
Sorry about the screw up!
"If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|