# Gradual alpha fade

**URL:** <https://forum.kirupa.com/t/gradual-alpha-fade/27710>\
**Category:** Uncategorized\
**Created:** [August 5, 2003, 8:30pm UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710 "2003-08-05T20:30:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rolando\_lopez](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@rolando\_lopez](https://forum.kirupa.com/u/rolando_lopez)\
**Post date:** [August 5, 2003, 8:30pm UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710/1 "2003-08-05T20:30:57Z")

</div>

Hi,

I am trying to create a fade effect. When I click on a movie clip, I want the others to gradually fade from \_alpha =100 to \_alpha = 25. The way I have it now it will instantly take the clip from 100 to 25.

This is on the movie clip that I click  
[AS]  
on(release){   
this.gotoAndStop(2);  
\_root.disappear();  
}[/AS]

This is the function definition on the root:  
[AS]  
function disappear(){  
for(var i = 100; i \> 25; i–){

```
_root["clip1"]._alpha = i;
}

```

}  
[/AS]

Can you guys help me out?

Thanks

---

<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:** [August 5, 2003, 8:46pm UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710/2 "2003-08-05T20:46:33Z")

</div>

for loops do the process then show the final result. You would need to use an event handler (onEnterFrame in this case) to gradually fade your clip…

[AS]function disappear(){  
//call onEnterFrame dynamic event handler  
\_root[“clip1”].onEnterFrame = function(){  
//decrement alpha by 5  
this.\_alpha -= 5  
//if the alpha is less than or equal to 25  
if (this.\_alpha \<= 25){  
//set the alpha to 25  
this.\_alpha = 25  
//delete the onEnterFrame to stop decrementing the alpha  
delete this.onEnterFrame  
}  
}

}[/AS]

---

<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:** [August 6, 2003, 6:00am UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710/3 "2003-08-06T06:00:12Z")

</div>

can you explain the significance of calling  
\_root[“clip1”].onEnterFrame

instead of just calling  
clip1.onEnterFrame  
or  
\_root.clip1.onEnterFrame.

does it have to do with arrays?

---

<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:** [August 6, 2003, 6:19am UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710/4 "2003-08-06T06:19:38Z")

</div>

In this case there is no difference, just personal preference.

---

<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:** [August 6, 2003, 10:24am UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710/5 "2003-08-06T10:24:42Z")

</div>

its nothing with arrays, just that if there is a variable, and you want to target the mc with the instance name of the value of the variable, or something similar, you use \_root[variable] or \_root[“movieclip”+i]

---

<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:** [August 6, 2003, 12:38pm UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710/6 "2003-08-06T12:38:21Z")

</div>

Lostinbeta,  
thanks. That worked great!

---

<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:** [August 6, 2003, 5:23pm UTC](https://forum.kirupa.com/t/gradual-alpha-fade/27710/7 "2003-08-06T17:23:11Z")

</div>

kartik: It is something with arrays. It is called associative array referencing. All the items in a timeline are stored in an array, and you can target that timelines array to get the clip/variable you want in the method you showed.

rolando: Cool :thumb:
