Copy link to clipboard
Copied
I have an array with 6 items. I have a for loop that dynamically builds a movie clip and loads the images. I'm trying to get an action/function to start only when the last image is finished loading I have the onLoadComplete working, but I cant seem to figure out how to get it to work on the last image and then activate an action/function?
Wil I need to find another way of looping them using the onloadcomplete as a singnal to load the on image and then the other?
Can anybody help?
you can use a variable to count the number of loaded images if you don't want to load them sequentially:
var imagesLoaded:Number=0;
whateverLO.onLoadComplete=function(mc:MovieClip){
imagesLoaded++;
if(imagesLoaded==yourarray.length){
callyourfunction();
}
}
Copy link to clipboard
Copied
you can use a variable to count the number of loaded images if you don't want to load them sequentially:
var imagesLoaded:Number=0;
whateverLO.onLoadComplete=function(mc:MovieClip){
imagesLoaded++;
if(imagesLoaded==yourarray.length){
callyourfunction();
}
}
Copy link to clipboard
Copied
Thank you Kglad! I was able to get the script working. If I could bother you with a minor problem with the script? its with the depths. I had better controll over depths in AS3, but I need to write in AS2. Any way with the script, before I added the tweens I was able to stack the images one ontop of the other, and then set the depth of the banner_mc above the images, but when I go to tween them they are infront of the banner. How can I get that banner on top (of everything else)?
import mx.transitions.Tween;
import mx.transitions.easing.*;
var MCL:Number
var listener:Object = new Object()
napolpics = new Array()
napolpics = [
"estimates_1_sm.jpg",
"directions_1_sm.jpg",
"partners_3_sm.jpg",
"home_4_lg.jpg",
"estimates_2_sm.jpg",
"about_4_lg.jpg"
]
MC_Tween = new Array
MC_Tween = []
for (var i=0; i < napolpics.length; i++)
{
var imagesLoaded:Number=0;
var container:MovieClip = this.createEmptyMovieClip("big_"+i, this.getNextHighestDepth());
MC_Tween.push(container);
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip(napolpics, container);
container._y=75;
container._x=10;
container.height=161;
container.width=194;
this.onLoadComplete = function(mc:MovieClip)
{
imagesLoaded++;
if(imagesLoaded==napolpics.length)
{
var tweenit=setTimeout(callyourfunction, 3000);
MCL= MC_Tween.length-1
}
}
}
function TweenImages()
{
trace (MCL)
var fadeit = new Tween(MC_Tween[MCL], "_X", Strong.easeInOut, MC_Tween[MCL]._x, 300, 4, true);
fadeit.onMotionFinished=function()
{
MCL--
if(MCL>-1){var tweenit=setTimeout(TweenImages, 3000);}
else{clearTimeout(tweenit)}
}
};
Copy link to clipboard
Copied
assign your banner's depth to be napolpics.length
Copy link to clipboard
Copied
thanks...that confuses me on why they chose to use swapdepth to set a depth
Find more inspiration, events, and resources on the new Adobe Community
Explore Now