# Please help! SetInterval for \_alpha fade out

**URL:** <https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885>\
**Category:** flash\
**Created:** [August 19, 2003, 8:02pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885 "2003-08-19T20:02:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![artane](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@artane](https://forum.kirupa.com/u/artane)\
**Post date:** [August 19, 2003, 8:02pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/1 "2003-08-19T20:02:25Z")

</div>

Hey guys,

This is probably very easy for you but, it’s really messing me up.

I’ve got a movie clip (main) that contains a button (stop) and a nested movie clip (animation). When the user clicks the button, I want the animation to fade out.

I’m pretty sure I need to employ the “SetInterval” function but, I am lost on exactly how. Could you please help me out with the script?

Thanks alot, I really appreciate your help.

Artane

---

<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 19, 2003, 8:28pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/2 "2003-08-19T20:28:33Z")

</div>

```auto
this.onPress = function () {
animation.onEnterFrame = function () {
this._alpha -= 5 ;
}
}

```

Like this?

---

<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 19, 2003, 8:33pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/3 "2003-08-19T20:33:03Z")

</div>

Place this on the first frame of your main timeline:  
[AS]  
function fadeout(path, speed) {  
path.onEnterFrame = function() {  
path.\_alpha -= speed;  
if (path.\_alpha\<=0) {  
delete path.onEnterFrame;  
}  
};  
}  
[/AS]

Then, you can call the function from anywhere. Assign this code to the button:

[AS]  
on(release){  
fadeout(\_root.moviecliptofadeout,speed)  
}  
[/AS]

Where \_root.moviecliptofadeout is the path to the movieclip you want to fade out. This can be any movieclip. speed defines how fast it will fade,The higher this value, the faster the movieclip will fade out. eg  
[AS]  
on(release){  
fadeout(\_root.moviecliptofadeout,20)  
}[/AS]

will fade out faster than  
[AS]  
on(release){  
fadeout(\_root.moviecliptofadeout,10)  
}  
[/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 19, 2003, 8:35pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/4 "2003-08-19T20:35:01Z")

</div>

… I talked too much again 😛

---

<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 19, 2003, 8:36pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/5 "2003-08-19T20:36:15Z")

</div>

If I may say so, it’s rather dangerous to use the \_root.onEnterFrame (you never know what you may be erasing), especially in your example Voetsjoeba, where you know the path to the clip, and therefore can use it’s onEnterFrame 🙂

Edit: crossposting again 😛

---

<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 19, 2003, 8:37pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/6 "2003-08-19T20:37:16Z")

</div>

Sorry, that should’ve been path.onEnterFrame _changes_

Now I’m doubting path.onEnterFrame again 😛 ! Is that the correct code ? By the way, in your code, won’t the onEnterFrame keep running ? Or does that stop along with the function ? Not really sure, but to be sure I always delete the 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:** [August 19, 2003, 8:38pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/7 "2003-08-19T20:38:41Z")

</div>

Sure, sure… :bad:

[size=1]only joking…[/size]

---

<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 19, 2003, 9:49pm UTC](https://forum.kirupa.com/t/please-help-setinterval-for--alpha-fade-out/28885/8 "2003-08-19T21:49:24Z")

</div>

Wow,

Thanks guys, all of this over me? I got it now!

I’m happy again,

artane
