# Basic Flash/ActionScript question

**URL:** <https://boards.straightdope.com/t/basic-flash-actionscript-question/396078>\
**Category:** Factual Questions\
**Created:** [March 15, 2007, 8:04pm UTC](https://boards.straightdope.com/t/basic-flash-actionscript-question/396078 "2007-03-15T20:04:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)\
**Post date:** [March 15, 2007, 8:04pm UTC](https://boards.straightdope.com/t/basic-flash-actionscript-question/396078/1 "2007-03-15T20:04:32Z")

</div>

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:

```auto

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.

---

<div class="post-metadata">

**Author:** ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)\
**Post date:** [March 15, 2007, 11:52pm UTC](https://boards.straightdope.com/t/basic-flash-actionscript-question/396078/2 "2007-03-15T23:52:07Z")

</div>

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):

```auto

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

```
