This segment creates the MCs for a preloaded slideshow. I want it to skip the creation of the MC and loader at the current index in the loop if a variable at that index is false, and then decrement the index and slideshow_length variable by one.
Looking at the code now, I suspect I need to pass si to another variable at each trip through the loop, and decrement that instead. But that still doesn’t seem to explain why the else condition isn’t tripping. Does it?
function init_slideshow():Void {
for (si = 1; si < parseInt(slideshow_length) + 1; si++) {
//sets default of all play_slide vars to true if not already defined [works]
if (_level0['play_slide' + si] == undefined) {
_level0['play_slide' + si] = true;
//create loader and mc at idx if play_slide at idx is true [works]
if (_level0['play_slide' + si] == true) {
this['slide_loader' + si] = new MovieClipLoader();
this.createEmptyMovieClip('slide_mc' + si, this.getNextHighestDepth());
}
else {
//else, decrement idx; decrement slideshow_length variable [doesn't work]
//else statement never trips, even when if returns false
si--;
_level0.slideshow_length--;
}
curr_ld = this['slide_loader' + si];
curr_mc = _level0['slide_mc' + si];
//load image into corresponding loader at idx
curr_ld.loadClip(slide_path + slide_name + si + slide_ext, curr_mc);
//hide all slides initially
curr_mc._alpha = 0;
curr_mc._x = Stage.width;
curr_mc._y = Stage.height;
}
//report loading of final image
if (si >= slideshow_length) {
curr_ld.addListener(slide_loader_listener);
slide_loader_listener.onLoadInit = function(target_mc:MovieClip) {
trace("last image loaded: " + target_mc);
};
}
}
}