Hi,
I'm using the Loader class in AS3.0 to load external images. I need to load a random image each time and I'm using a timer to load a new image after 5 seconds or so. When I load the first image, I call...
myMovieClip.addChild(loader);
After the first time I call...
if (myMovieClip.numChildren > 0) {
myMovieClip.addChildAt(loader, 1);
}
So, this should add the newly loaded image behind the first one...that seems to be working...
The next step I want to do is to fade between these two clips, so the one in front fades out over a couple of seconds and is then finally removed when it is invisible. After another few seconds I load the next one and repeat the process.
At present, I start a timer and when it fires I do this...
if (Loader(myMovieClip.getChildAt(0)).content.alpha <= 0)
{
// Check if the alpha value is 0...if so, remove the image and stop the timer
myMovieClip.removeChildAt(0);
timer.stop();
}
else
{
// Increase transparency
Loader(myMovieClip.getChildAt(0)).content.alpha -= 0.1;
}
The problem is that my fading routine does not work. One image loads, and the next one appears straight away when it is finished loading.
My code feels like a bit of a hack...is there a nicer way that actually works...?