# Loading and fading movie clips

**URL:** <https://forum.kirupa.com/t/loading-and-fading-movie-clips/56752>\
**Category:** Uncategorized\
**Created:** [July 7, 2004, 3:17pm UTC](https://forum.kirupa.com/t/loading-and-fading-movie-clips/56752 "2004-07-07T15:17:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlashInthePan](https://avatars.discourse-cdn.com/v4/letter/f/45deac/32.png) [@FlashInthePan](https://forum.kirupa.com/u/FlashInthePan)\
**Post date:** [July 7, 2004, 3:17pm UTC](https://forum.kirupa.com/t/loading-and-fading-movie-clips/56752/1 "2004-07-07T15:17:51Z")

</div>

Hi  
New to flash but not to programming. Need help on two things:  
If i need to load movie clips from library onto the stage one after the other. How do i make the second clip load only after the first stops playing. The main time line i have has only one frame.  
I need to make a movie clip on stage fade away using action script. I tried to use a loop to decrement the alpha value but flash discards the script saying that it would make the system unstable (it really does) . Any solutions or work arounds??

thanks in advance

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 7, 2004, 6:21pm UTC](https://forum.kirupa.com/t/loading-and-fading-movie-clips/56752/2 "2004-07-07T18:21:42Z")

</div>

use onEnterFrame actions:

```auto

//attachcode
_root.attachclip1.onEnterFrame = function() {
	this._alpha -= 10;
	if(this._alpha <= 0) {
		//attach second clip
		this.removeMovieClip();
	}
}

```

Hopefully thats helps 😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 8, 2004, 1:25am UTC](https://forum.kirupa.com/t/loading-and-fading-movie-clips/56752/3 "2004-07-08T01:25:10Z")

</div>

Thanks  
it works for two movie clips with fixed names. What if i want to go through a list of movies in the library (jpeg images stored as movie clips ) and make them appear and fade one by one? The main timeline is one frame so is the movie:) how do i keep running the piece of code above every time a new movie loads. I guess i can if i put some code in the first frame of every movie but i would like to avoid that

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 8, 2004, 2:07pm UTC](https://forum.kirupa.com/t/loading-and-fading-movie-clips/56752/4 "2004-07-08T14:07:31Z")

</div>

```auto

i = 0;
function makeClip() {
	init = new Object(); //creates a new blank object for the initiating actions
	init._x = 300; //desired x position
	init._y = 300; //desired y position
	init.onEnterFrame = function() { //inits onEnterFrame action
		this._alpha -= 10;
		if(this._alpha <= 0) {
			_root.i++;
			_root.makeClip(); //create another movieclip
			this.removeMovieClip();
		}
	}
	_root.attachMovie("clip"+_root.i, "clip"+_root.i, _root.getNextHighestDepth(), init); //attach clip using init object so movie clip initiates with parameters specified ini init object
}
makeClip();

```

This will use a function to attach a clip with name clip+i where i is a number to make the clip name unique, so have the linkage name of your clips clip+i and increment i in the order you want the images displayed. Once the \_alpha of the clip equals 0 it increments the i variable so the next clip loaded is different, runs the makeClip function again, creating another clip, and then removes itself. Hope that makes sense.
