# Fade in loop?

**URL:** https://forum.kirupa.com/t/fade-in-loop/33769
**Category:** Uncategorized
**Created:** [October 23, 2003, 1:09pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769 "2003-10-23T13:09:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Inflicted](https://avatars.discourse-cdn.com/v4/letter/i/82dd89/32.png) [@Inflicted](https://forum.kirupa.com/u/Inflicted)
#### Post date: [October 23, 2003, 1:09pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769/1 "2003-10-23T13:09:48Z")

</div>

This is a follow up question to an earlier thread. Someone helped me with some code, but actually made it to difficult for me to understand.  
I want to fade the pictures in this loop in:

```auto
for (i=1; i<=6; i++) {
    loadMovie("images/image"+i+".jpg", "container_"+i);
    this["container_"+i].onload = function() {
        this["container_"+i]._alpha = 0;
    };
}

```

Searched for examples, but couldn’t find a simple one(drives me crazy!)

thanks

regards

\*wanted to post in AS forum but made mistake. Is it possible to move it there?

---

<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: [October 23, 2003, 5:59pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769/2 "2003-10-23T17:59:20Z")

</div>

```auto

for (i=1; i<=6; i++) {
mc = this["container_"+i];
mc.loadMovie("images/image"+i+".jpg");
mc.onload = function() {
this._alpha = 0;
};
mc.onEnterFrame = function(){
this._alpha < 100 ? this._alpha += 10 : delete this.onEnterFrame
}
}

```

🙂

---

<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: [October 23, 2003, 6:16pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769/3 "2003-10-23T18:16:20Z")

</div>

Thanks Voetsjoeba,

For some reason it doesn’t work. My code is probably wrong in the first place.  
Included the file with the pics:

www.inflicted.nl/pictures.zip

Hope you can help

regards

---

<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: [October 23, 2003, 6:28pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769/4 "2003-10-23T18:28:06Z")

</div>

```auto
function preload() {
	var loaded = this.temp_mc.getBytesLoaded();
	var total = this.temp_mc.getBytesTotal();
	this.onEnterFrame = loaded>0 && loaded == total ? fadein : preload;
}
var fadespeed = 10;
function fadein() {
	this._alpha = Math.min(100, this._alpha+fadespeed);
	this.onEnterFrame = this._alpha == 100 ? undefined : fadein;
}
for (var i = 1; i<=6; i++) {
	var mc = this["container_"+i];
	mc.createEmptyMovieClip("temp_mc", 0);
	mc.temp_mc.loadMovie("images/image"+i+".jpg");
	mc._alpha = 0;
	mc.onEnterFrame = preload;
}

```

---

<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: [October 23, 2003, 6:38pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769/5 "2003-10-23T18:38:56Z")

</div>

Kode!  
This is great!  
What I don’t understand is that you create an empty MC, “temp\_mc” and the images still load in the container\_MC’s.  
Could you explain a little?

Thanks a million

regards

---

<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: [October 23, 2003, 6:50pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769/6 "2003-10-23T18:50:21Z")

</div>

That’s because the empty movie clip, temp\_mc, is created inside the other movie clip, container\_#!! 😉  
Run a search in the forum if you want the whole explanation, it’s been asked many times.

And you’re welcome. 😛

---

<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: [October 23, 2003, 6:59pm UTC](https://forum.kirupa.com/t/fade-in-loop/33769/7 "2003-10-23T18:59:08Z")

</div>

Thanks to Voetsjoeba also…

regards
