PDA

View Full Version : Animating movement with actionscript



burningcurio
February 14th, 2008, 11:43 AM
I'm looking to be able to control the movement of a movie clip with acitonscript, specifically when i click a button, i would like my movieclip to slide, not jump, to a specific location. I am currently using cs3, but AS 2.0. And if i could add easing, that would be even better.

So far, all I'm able to make it do is jump to that specified location. It looks bad.

Any ideas? Or at least point me in the right direction?

Thanks,
Jen

Jackchalat
February 14th, 2008, 07:23 PM
The easiest way to do this is to use some sort of Tweening class. You will need some knowledge with OOP (Object-Oriented Programming), but it's all worth it.

I suggest GreenSock's TweenLite for AS2
http://blog.greensock.com/tweenliteas2

bataglia
February 15th, 2008, 04:20 AM
in cs3 you have already some tweens - mx tweens. Search in flash and you will see also some nice examples.

excogitator
February 15th, 2008, 05:53 AM
You can use motion tweening using AS 2 as well.
Try the below code
===========================
import mx.transitions.Tween;
import mx.transitions.easing.*;

new Tween(mymovieclip, "_x", Elastic.easeOut, 20, 400, 2, true);

where 20 is from position and 400 is till position which can be replaced by variables having dynamic values as well

However as mentioned above Tweenlite is better than the inbuilt tweener classes when making major bugfree flash apps as inbuilt tween classes gather some garbage collections which need to be handled

gubba1986
February 15th, 2008, 05:56 AM
i think it is helpful to you

check it




my_btn.onRollOver=function(){
_root.stop();
}

thanx,
Gubba

phsector
February 15th, 2008, 10:58 AM
If You use AS3 try this

http://tweener.googlecode.com/files/tweener_1_26_62_as3.zip

info: http://labs.zeh.com.br/blog/?p=93

Example:

import caurina.transitions.Tweener;

Tweener.addTween(_mc, {x: 400, y:200, time:5, transition:"linear", onComplete:makeSomething});

function makeSomething():void{
trace("finish!!");
}


------

Pier25
February 18th, 2008, 06:25 AM
with AS2 you can use fusekit which is really easy to install and works great

http://www.mosessupposes.com/Fuse/

example in it's simplest form:

my_movieclip.alphaTo(0,3)

alpha to 0 in 3 seconds

or

my_movieclip.tween("_alpha",0,3);

It can become more complicated... you can change the easing curve, put some callback, delays, change various properties at the same time, make sequences of tweens, etc.