# Problem with if statement

**URL:** <https://forum.kirupa.com/t/problem-with-if-statement/232978>\
**Category:** Uncategorized\
**Created:** [July 19, 2007, 5:56am UTC](https://forum.kirupa.com/t/problem-with-if-statement/232978 "2007-07-19T05:56:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwh](https://avatars.discourse-cdn.com/v4/letter/g/bbe5ce/32.png) [@gwh](https://forum.kirupa.com/u/gwh)\
**Post date:** [July 19, 2007, 5:56am UTC](https://forum.kirupa.com/t/problem-with-if-statement/232978/1 "2007-07-19T05:56:30Z")

</div>

Hi everyone,

The code at the end of this post is code I have on frame 1 of the main timeline.

The movieclip called intro\_mc is first called on to play with this code:

```auto
intro_mc.onEnterFrame = function () {
this.play();
delete intro_mc.onEnterFrame;
}

```

Then the movieclip called categoryIndex\_mc is set to fade in gradually using the rest of the code.

The problem is that categoryIndex\_mc fades in at the same time that intro\_mc is playing. I need intro\_mc to reach the end of its timeline before categoryIndex\_mc will come in. I tried enclosing the function in an if statement but this just caused categoryIndex\_mc not to appear at all.

Can someone tell me how to correct the code?

Appreciate any help offered.

```auto
//-----------Initialization---------\\
this.categoryIndex_mc._alpha = 0;
this.garmentSlides_mc._alpha = 0;
//-----------------------------------\\

intro_mc.onEnterFrame = function () {
this.play();
delete intro_mc.onEnterFrame;
}

//-----------Category list fades in---------\\

var oIntervalIDs:Object = new Object();

if (this.intro_mc._currentframe == 60) {
	function fadeMovieClip (mClip:MovieClip, nRate:Number):Void {
		if(mClip._alpha >= 0 && mClip._alpha < 100) {
			 var nAlpha:Number = mClip._alpha;
			mClip._alpha = nAlpha + nRate;
			updateAfterEvent();
		}
	else {
		clearInterval(oIntervalIDs[mClip._name]);
		}
	}
}
oIntervalIDs[categoryIndex_mc._name] = setInterval(fadeMovieClip, 100, categoryIndex_mc, 5);

categoryIndex_mc.onEnterFrame = function () {
if(categoryIndex_mc._alpha > 95) {
	this.indexBack_mc.gotoAndPlay(30);
	delete categoryIndex_mc.onEnterFrame;
}
}

```
