View Full Version : easing movement
dudeness
October 4th, 2003, 05:57 AM
I looked everywhere on the forums but couldnt find the basic script to move a box from position x to another position by clicking on a button and easing the movement when it stops.
you can probably write down the code in no time.
thx
Voetsjoeba
October 4th, 2003, 06:25 AM
[AS]box.onEnterFrame = function(){
this._x = targetX-(targetX-this._x)/1.2
this._y = targetY-(targetY-this._y)/1.2
}[/code]
Welcome to the forums ! =)
dudeness
October 4th, 2003, 07:21 AM
thx, but i am a real noob so i dont quite understand this..maybe you could be so kind and make a quick example fla?
thanks for the welcome btw ;)
Lews
October 4th, 2003, 07:48 AM
Set the FPS of your movie to 24.
Convert the graphic you want to move with easing to a movieclip.
Give it an instance name (we'll use "box" as instance name in this example).
Place a button on your stage.
Give the button an instance name (we'll use "button" in this example)
Add this code to the button (thanks Voets ;)):
on(release){
box.onEnterFrame = function(){
this._x = _root.button._x-(_root.button._x-this._x)/1.2
this._y = _root.button._y-(_root.button._y-this._y)/1.2
}
}
You can replace _root.button._x and _root.button._y with the x and y values you want your graphic to move to.
dudeness
October 4th, 2003, 11:34 AM
i replaced the _x like this :
this._x = _root.button._45-(_root.button._45-this._x)/1.2
but it doest work? is it right?
Voetsjoeba
October 4th, 2003, 11:39 AM
targetX is the value to ease to. So it either has to be _root.button._x or 45. You can't use _root.button._45 :)
dudeness
October 4th, 2003, 01:11 PM
ah hehe, as i said i'm lame...
thanks alot!
Voetsjoeba
October 4th, 2003, 01:13 PM
You're welcome :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.