View Full Version : Please help! SetInterval for _alpha fade out
artane
August 19th, 2003, 04:02 PM
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
pom
August 19th, 2003, 04:28 PM
this.onPress = function () {
animation.onEnterFrame = function () {
this._alpha -= 5 ;
}
}Like this?
Voetsjoeba
August 19th, 2003, 04:33 PM
Place this on the first frame of your main timeline:
function fadeout(path, speed) {
path.onEnterFrame = function() {
path._alpha -= speed;
if (path._alpha<=0) {
delete path.onEnterFrame;
}
};
}
Then, you can call the function from anywhere. Assign this code to the button:
on(release){
fadeout(_root.moviecliptofadeout,speed)
}
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
on(release){
fadeout(_root.moviecliptofadeout,20)
}
will fade out faster than
on(release){
fadeout(_root.moviecliptofadeout,10)
}
Voetsjoeba
August 19th, 2003, 04:35 PM
... I talked too much again :P
pom
August 19th, 2003, 04:36 PM
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 :P
Voetsjoeba
August 19th, 2003, 04:37 PM
Sorry, that should've been path.onEnterFrame *changes*
Now I'm doubting path.onEnterFrame again :P ! 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.
pom
August 19th, 2003, 04:38 PM
Sure, sure... :bad:
only joking...
artane
August 19th, 2003, 05:49 PM
Wow,
Thanks guys, all of this over me? I got it now!
I'm happy again,
artane
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.