# Else not tripping even when If condition fails

**URL:** <https://forum.kirupa.com/t/else-not-tripping-even-when-if-condition-fails/302228>\
**Category:** flash\
**Created:** [December 23, 2009, 8:27pm UTC](https://forum.kirupa.com/t/else-not-tripping-even-when-if-condition-fails/302228 "2009-12-23T20:27:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibsen](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@ibsen](https://forum.kirupa.com/u/ibsen)\
**Post date:** [December 23, 2009, 8:27pm UTC](https://forum.kirupa.com/t/else-not-tripping-even-when-if-condition-fails/302228/1 "2009-12-23T20:27:19Z")

</div>

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?

```auto
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);
			};
		}
	}
}

```
