Basic Flash/ActionScript question

I feel like an idiot. I’m just playing around with ActionScript, and I’m trying to create a title page where two movie clips fade in. One is a dynamic text movie clip, the second is an image that is loaded.

My code is this:



function fadeIn():Void {
	this._alpha += 10;
	if (this._alpha>100) {
		this._alpha = 100;
		delete this.onEnterFrame;
	}
}
title_mc._alpha = 0;
title_mc.onEnterFrame = fadeIn;
image_mc.loadMovie("image0.jpg");
image_mc._alpha = 0;
image_mc.onEnterFrame = fadeIn;


I’ve traced the heck out of this, so all I know is that image_mc seems to only generate a single onEnterFrame event and then stops. What obvious, basic Flash point am I missing here?

It seems that if I comment out the .loadMovie line, the placeholder movie clip fades in properly, so obviously there is something about onEnterFrame events and loadMovie that I don’t know.

Also, is this a tidy way to code this, or is there a cleaner way? Something tells me the code should be a little prettier than this.

Found the answer out, so I’ll just post it for posterity’s sake. Basically, loadMovie kills all code associated with the clip, including onEnterFrame events. The solution was to nest image_mc in another movie clip and fade that clip.

In other words (after having restructured the code into a function):



function showImage(filename:String):Void {
	imagePlaceholder_mc.image_mc.loadMovie(filename);
	imagePlaceholder_mc._alpha = 0;
	imagePlaceholder_mc.onEnterFrame = fadeIn;
}