Groups | Blog | Home
all groups > flash actionscript > september 2005 >

flash actionscript : on (rollOver), how do I fade?


Motion Maker
9/30/2005 4:44:50 PM
Here is my no code idea:

Two movie clips fade in and fade out. Tween the button image in both one
tween 100 to 50 and the other 50 to 100. A stop action on last frame of
both.

Place the movie clips on the button frames Up get FadeIn, Over get FadeOut
and Down FadeIn.



--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!

Centerpoint Computer
9/30/2005 6:14:15 PM
Using actionscript, I have adjusted the alpha of a movie clip when I rollOver
it and restored it when I rollOut. It is an abrupt change:

on (rollOver) {
this._alpha = 50;
}
on (rollOut) {
this._alpha = 100;
}

Now I'd like to adjust the script to fade the alpha from 100 to 50 and fade
back to 100 from 50 when the mouse handlers are invoked.

do I use a while loop? Do I create a function? Not sure at this point.
Motion Maker
9/30/2005 11:01:01 PM
[quoted text, click to view]
using the front end.

Then consider using setInterval to change the alpha value.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]

NSurveyor
10/1/2005 12:54:08 AM
Inside the movieclip have a motion tween from _alpha 50 to _alpha 100. Then, read this:

Centerpoint Computer
10/1/2005 2:02:40 AM
Thanks guys. Unfortunately, I'd like to learn how to script this instead of
using the front end. That link shows actionscript that applies to a button.
The clips that I am affecting are not marked as buttons, but from what I
understand, they take on the behavior of buttons when button handlers are used
in the script.
NSurveyor
10/1/2005 11:05:00 AM
Actually the code I provided will ONLY work with movieclips. What gave you the
idea it was for buttons? (perhaps, my_btn?) Try this:

on (rollOver) {
this.onEnterFrame = function(){
this._alpha-=5;
if(this._alpha<=50){
this._alpha = 50;
delete this.onEnterFrame;
}
}
}
on (rollOut) {
this.onEnterFrame = function(){
this._alpha+=5;
if(this._alpha>=100){
this._alpha = 100;
delete this.onEnterFrame;
}
}
}

AddThis Social Bookmark Button