PDA

View Full Version : Simple Tweening with ActionScript


mnik
02-26-2002, 07:35 AM
I want to roll over a button that causes a MovieClip of text (a description of the content) to change it's alpha from 0 to 100 over a series of frames using ActionScript.

I'm able to make it appear abruptly:

on (release) {
setProperty (_root.myMC, _alpha, 10);
}

...But want it to gradually appear. I know the solution lies in adding the framerate to the parameters, but I'm stumped.

(Yes I know I can do this by manually tweening the clip, but hey -I'm learning Actionsript!)

Thanks in advance.

sfa
02-26-2002, 07:50 AM
you need to put a script on a control movie. Create a movie and place this code on it (select it in the main timeline-

onClipEvent(enterFrame){
if(_root.moviename._alpha > 1)
_root.moviename._alpha -= 1;
}
i think there is a tutorial about tweening with actionscript on this site in the tutorial section.

SFA

mnik
02-26-2002, 09:02 PM
Thanks for you input. However, I wish to have this work only when a button is moused over. If I understand correctly your script changes the alpha without user interaction.

How can I call this script only from the button?
Thanks!

p.s. I checked out the tutorial you reccomended on the site, but it wasn't much help to me in this scenario.

tg
02-26-2002, 09:41 PM
on(rollOver){
_root.changeAlpha=true;
}
on(rollOut){
_root.changeAlpha=false;
}

//on mc
onClipEvent(enterFrame){
if(_root.changeAlpha){
if(_root.moviename._alpha > 0) {
_root.moviename._alpha -= 1;
}
}
}