Please help! SetInterval for _alpha fade out

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

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

Like this?

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]

… I talked too much again :stuck_out_tongue:

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

Edit: crossposting again :stuck_out_tongue:

Sorry, that should’ve been path.onEnterFrame changes

Now I’m doubting path.onEnterFrame again :stuck_out_tongue: ! 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.

Sure, sure… :bad:

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

Wow,

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

I’m happy again,

artane