PDA

View Full Version : simple script problem (easing alpha channel)


Gostop01
02-26-2003, 05:31 AM
So I need to drop my alpha on rollover and bring it back to 100 on rollout. Whats the easiest way using actionscipt for me to have it gradually change and not be so instant.

//start code
on(rollOver){
_root.menu.visuals.visualsbut._alpha=80;
}
on(rollOut){
_root.menu.visuals.visualsbut._alpha=100;
}
//end code


I appreciate the help.
thanks.

Billy T
02-26-2003, 05:34 AM
are you using mx?

Gostop01
02-26-2003, 05:36 AM
Yes I am using MX.

Billy T
02-26-2003, 05:39 AM
make your button an mc

give it an instance name of mcbut

then use

mcbut.onRollOver=function(){
this.onEnterFrame=function(){
if(this._alpha>80){
this._alpha-=5;
}else{
this.onEnterFrame=null;
}
}
}
mcbut.onRollOut=function(){
this.onEnterFrame=function(){
if(this._alpha<100){
this._alpha+=5;
}else{
this.onEnterFrame=null;
}
}
}

cheers

Gostop01
02-26-2003, 06:02 PM
Is the suggested script just an OnClipEvent(enterframe)? Or is it something else. I tried that and I get alot of error messages.

Can someone give me the script exactlly as it should be written? Thanks.

binkyboo
02-26-2003, 09:08 PM
Billy's code is exactly how it should be written.

Gostop01
02-27-2003, 03:29 AM
Great thanks. I was still attaching the script to the object instead of the frame.

this works great but is there any reason why my down button state no longer works??

Billy T
02-27-2003, 03:36 AM
was it an mc or a button? did you just change the drop down in the property inspector to tell it to act as a movieclip?

maybe up the file

cheers

Gostop01
02-27-2003, 03:47 AM
maybe this complicates things but here is the layout:

_ROOT>MC1>MC2>MC3>BUTTON

the script you gave me is applied to MC2.
The button is really basic. just a colorchange for the over & down state.

Any ideas why the Button overstate isnt working now?

Billy T
02-27-2003, 04:10 AM
because you have a button inside a button (even though one of them is an mc that you have given button actions)

go inside mc2 and make these frame label

_up

_over

_down

put different graphics inside each and flash will jump between them at the appropriate time. put a stop action in frame 1 of this mc as well

cheers

Gostop01
02-27-2003, 04:58 AM
ok thanks.
does this mean my original button is meaning less?

Billy T
02-27-2003, 05:05 AM
yep