what would be the best way to control a mc’s alpha with actionscript. i need to be able to fade a mc with various buttons
thanks
what would be the best way to control a mc’s alpha with actionscript. i need to be able to fade a mc with various buttons
thanks
[AS]function alphaFade(clipToFade, finalAlpha, speed) {
clipToFade.onEnterFrame = function() {
this._alpha += (finalAlpha-this._alpha)/speed;
if (Math.floor(this._alpha) == Math.floor(finalAlpha)) {
this._alpha = finalAlpha;
delete this.onEnterFrame;
}
};
}
myButtonInstanceName.onPress = function() {
alphaFade(myMovieClip, 20, 10);
};[/AS]
If you don’t want to use dynamic event handlers you can just use
[AS]on (press) {
alphaFade(myMovieClip, 20, 10);
}[/AS]
Change the parameters to whatever you want. myMovieClip is the clip you want to fade, 20 is the final alpha value, and 10 is the speed of the fade.
I hope this helps.
*Originally posted by Ilyas *
**http://www.kirupaforum.com/forums/showthread.php?s=&threadid=4016 **
Posted at the same time
thank you guys! ya know i saw soemthing about this the other day but i couldn’t find the post #
*Originally posted by Digitalosophy *
**thank you guys! ya know i saw soemthing about this the other day but i couldn’t find the post # **
Thats the glory of http://www.kirupaforum.com/forums/search.php?s=
lol ya man i know about the search, as if your header wasn’t good enough. thanks the script worked very well. this will come n super handy
hmm having a problem. i have buttons which are inbeded into movie clips. i am tryin gto refer to the mc as
[AS]
on(release){
_root.about_destination = 85;
alphaFade(_root.header, 20, 10);
}
[/AS]
dang i know this is a silly one but could ya give me a hand?
Can you describe what is embeded in what exactly?
never mind by using dynamic event handlers there is no problem… thanks again. but i had a movie clip with a button embeded in it that i wanted to control the mc that fades
Since it is a regular function and not a prootype you would need to target the timeline the function is on.
So _root.alphaFade(_root.header, 20, 10); probably would work.
ahh ok thanks
:: Copyright KIRUPA 2024 //--