PDA

View Full Version : Animation to not skip until all frames are animated



Lawliet
February 10th, 2009, 07:21 PM
Hello again,

I was following this tutorial:
http://schoolofflash.com/2008/05/flash-cs3-tutorial-movie-clip-buttons/

To make the buttons feel more smooth, can anyone modify the Actionscript to make it so that the animation on the "over" label not skip even if the mouse is no longer on the button or rerolls on the button too early?

(In other words, let the "over" animation finish even if the mouse leaves the button, thus letting it finish before it goes and animate the "out" label). I hope that isn't too confusing.

Like what this button is doing:
http://www.echoecho.com/flashbuttons02.htm
(On the "CREATING TELL TARGET BUTTONS" part)

Anil_kumar
February 11th, 2009, 01:40 AM
try this code



//AS3

import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;


var tweenReverseX;
var tweenReverseY;

stage.frameRate=30;
var mc_button:MovieClip = new MovieClip();
mc_button.graphics.beginFill(0xFF6532,1);
mc_button.graphics.drawRect(-25,-25,50,50);
mc_button.graphics.endFill();

mc_button.x=stage.stageWidth/2;
mc_button.y=stage.stageHeight/2;

mc_button.buttonMode=true;

mc_button.addEventListener(MouseEvent.MOUSE_OVER,m ouseOverListener);

addChild(mc_button);



function mouseOverListener(In_Event:MouseEvent) {

mc_button.removeEventListener(MouseEvent.MOUSE_OVE R,mouseOverListener);

scaleFunction(MovieClip(In_Event.target),"scaleX");
scaleFunction(MovieClip(In_Event.target),"scaleY");

}

function scaleFunction(movieClip:MovieClip,Property:String) {



if (Property=="scaleX") {

var myTweenX:Tween=new Tween(movieClip,Property,Regular.easeOut,1,2,1,tru e);

tweenReverseX=myTweenX;

tweenReverseX.addEventListener(TweenEvent.MOTION_F INISH, reverseFunctionX);

}

if (Property=="scaleY") {

var myTweenY:Tween=new Tween(movieClip,Property,Regular.easeOut,1,2,1,tru e);

tweenReverseY=myTweenY;

tweenReverseY.addEventListener(TweenEvent.MOTION_F INISH, reverseFunctionY);

}

}

function reverseFunctionX(IN_Event:TweenEvent) {

tweenReverseX.removeEventListener(TweenEvent.MOTIO N_FINISH, reverseFunctionX);

tweenReverseX.yoyo();

}

function reverseFunctionY(IN_Event:TweenEvent) {

tweenReverseY.removeEventListener(TweenEvent.MOTIO N_FINISH, reverseFunctionY);

tweenReverseY.yoyo();

mc_button.addEventListener(MouseEvent.MOUSE_OVER,m ouseOverListener);

}




Anil
Flash Workshop (http://flash-workshop.blogspot.com/)
anilkumarnd@gmail.com