Im having an issue scripting a super simple rollover animation. (sorry Im new to this…)
I scripted the rollover and it works except if you rollout before it reaches the rollover state… then it just stays there… instead of rolling back to its original, home state…
I couldn’t get your timeline animation to function correctly with your script.
I wrote a new script that appears to work correctly.
Everything is on frame1 of the main timeline.
stop();
import gs.TweenMax;
import fl.motion.easing.*;
/*
You may add more buttons to the movieclip container "buttonGroup".
Give them instance names "btn2" "btn3" "btn4" etc...
Add the new instance names to the switch/case/break nested in the CLICK function.
Replace the trace statements with your desired CLICK behaviors.
*/
buttonGroup.addEventListener(MouseEvent.CLICK, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.MOUSE_OVER, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.MOUSE_OUT, action, false, 0, true);
buttonGroup.mouseEnabled = false;
buttonGroup.buttonMode = true;
var buttonName:String = "";
function action(event:MouseEvent):void {
buttonName = event.target.name;
switch (event.type) {
case MouseEvent.MOUSE_OVER :
TweenMax.to(event.target, .6, {rotation:30, ease:Back.easeOut});
break;
case MouseEvent.MOUSE_OUT :
TweenMax.to(event.target, .6, {rotation:0, ease:Back.easeOut});
break;
case MouseEvent.CLICK :
trace("This happens if ANY button is clicked!");
switch (buttonName) {
case "btn1" :
trace("this happens if btn1 is clicked!");
break;
case "btn2" :
trace("this happens if btn2 is clicked!");
break;
case "btn3" :
trace("this happens if btn3 is clicked!");
break;
case "btn4" :
trace("this happens if btn4 is clicked!");
break;
}
break;
}
}