kz0007
June 13th, 2008, 03:39 PM
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..
please help..
THANKS!!!!
-krzys
I attached the fla.
snickelfritz
June 13th, 2008, 07:27 PM
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.
Rollover and rollout animations are handled by TweenMax (http://blog.greensock.com/tweenmaxas3/).
Download and install the class; it'll come in handy for other projects as well.
Example Site (http://www.byrographics.com/AS3/rockinButton/rockinButton.html)
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;
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.