View Full Version : animation using actionscript
Can anyone please tell me how to tween/animate a graphic(or movie clip)from one point to another purely using actionscript.(frame based,although mouse events are welcome)I have a limited knowledge of actionscipt and hav been trying for ages, but i cannot seem to get the coding right.
I will also be greatful for any variations on the theme e.g:controlling the speed,setting start and end points e.t.c.
Thanks for listerning
case
seventhmonkey
01-06-2001, 05:06 AM
This probably should have been asked in the actionscripting forum, and perhaps a nice mod will move it there for you, but anyway...
Say you have a mc to move with an instance name of "bob".
In the parent mc or main timeline do:
First Frame:
startypos = 25.4; //these are the start positions of the mc
startxpos = 34.1;
finishypos = 354.9; //these are the finish positions of the mc
finishxpos = 482.4;
ydist = finishypos - startypos; //this is the distance to be travelled
xdist = finishxpos - startxpos;
ymove = ydist/100; //this is the distance to be travelled each incrementation.
xmove = xdist/100;
Second Frame:
if (_root.bob._y<finishypos){
_root.bob._y = _root.bob._y + ymove;
}
if (_root.bob._x<finishxpos){
_root.bob._x = _root.bob._x + xmove;
}
Third Frame:
gotoAndPlay (2);
The bigger the number on the denominator of the fraction in the ymove/xmove variables, the slower the mc will move. This allows you to control the speed.
Hope taht taht helps you out/is what you were after. :)
Jesse
01-06-2001, 07:09 AM
Also see our new tutorial:
http://www.actionscripts.org/tutorials/intermediate/object_movement_mouse/index.shtml
Cheers
Jesse
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.