MC Positioning/Moving

hi guys, been a while, but still :smiley: I’ve got this scripting to move an MC:[AS]on (release) {
_x = 0;
_y = -170;
}[/AS]is there a way to code it so that eases into position rather than just jumps? And preferably without having to set up a motion tween? Any help appreciated!

http://www.kirupa.com/developer/mx/easing_mouseclick.htm

hm… ok thanks…
thing is… I dont want to go to my mouse position. there’s an up and a down arrow. want the MC to ease up with one and down with the other (obviously). Is there particular bits of this code that I need to isolate? is it just a case of adding the speed line?

That tutorial shows a theory. The theory of easing.

Easing follows a specific equation, and it is shown in that tutorial.

Whatever endX and endY equal, it will move there.

So to make it move to a new location, you have to change what endX and endY equal.

ooopsh! sorry lost… I think all this AS has sent me slightly crazy (-:

erk :confused: I really can’t work this out… :confused:

Well you would need to define an endX and endY variable to start with.

[AS]onClipEvent(load){
var endX = this._x
var endY = this._y
}[/AS]

Then when you release, you will want to set the value of the endX and endY variables

[AS]on (release){
endX = newPositionX;
endY = newPositionY;
}[/AS]

Then you run the onEnterFrame with the easing forumla.

ok, is there a way to set up a button so that it makes the MC move a certain distance everytime you click it - rather than having to set lots and lots of end points?

endX += amount
endY += amount

It will add whatever value you put for amount onto the current value of endX and endY

thnx lib, I literally just found this on a different thread:[AS]on(release){
_root.myMC._y+=5
}
[/AS]which is great, it moves the right amount, and endlessly, but I still cant get it easing nicely, it just jumps… do I have to set specific stop points for it to be able to ease? :frowning:

[AS]on(release){
_root.myMC._y+=5
}[/AS]

is entirely different from the method mentioned here.
http://www.kirupa.com/developer/mx/easing_mouseclick.htm

The easing formula requires you to state where you want the clip to go to by defining the endX and endY coordinates.

this._y+=5 just moves the clip every 5 pixels endlessly unless you use an if statement to detect its position and tell it to stay in the same spot if it is out of bounds.