|
|
 |
|
|
|
|
|
Hi all:
There is an easy tutorial of Transmission of Movement with easing.
a) We need a sprite motor (movement) with next code:
onEnterFrame() { moveTo = _root.destiny; pos_clipPresent = _root.clip._x; distance = moveTo-pos_clipPresent; speedMov = distance/5; _root.clip._x = _root.clip._x+speedMov;
}
3 Buttons(but1,but2,but3) or more with next code:
1st button:
on (release) { _root.destiny=but1._x } 2ond button:
on (release) { _root.destiny=but2._x } and so on.
c) The sprite that we want move, on our example is a square named "clip".
Well i try to explain a little, we have on the timeline a variable named "destiny", that have a 0 value when the movie start.But every button change destiny value, equaling the variable "destiny" to value x of the button:
_root.destiny=but2._x
Now we want see how works destiny variable with sprite "movement".On movement script we have a new variable that takes the value of "destiny".(moveTo)
moveTo = _root.destiny
after we check _x.clip position on this moment.
pos_clipPresent = _root.clip._x;
next steep we calculate the distance of the button position (moveTo) and sprite "clip" position (pos_clipPresent ):
distance = moveTo-pos_clipPresent;
Now we give a speed for the movement:
speedMov = distance/5;
and finally we come to move the sprite "clip".
_root.clip._x = _root.clip._x+speedMov;
Thatīs all.
Take a look Transmission of Movement
Enjoy
|
|
|
|