Easing problem

Hey everyone,

I was wondering if anyone could help with this problem I’m having.
Here is the code from this site for easing.
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent (mouseDown) {
endX = _root._xmouse;
endY = _root._ymouse;
}
onClipEvent (enterFrame) {
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
and here is mine I changed it a bit but I still don’t see why it doesn’t work?

onClipEvent (load) {
originalX = _x;
originalY = _y;
speed = 5;
}
onClipEvent (mouseUp) {
endX = _root._xmouse;
endY = _root._ymouse;
}
onClipEvent (enterFrame) {
originalX += (endX-originalX)/speed;
originalY += (endY-originalY)/speed;
}

if anyone could help me with this it would be great. Thanks A Lot

Kyle

originalX = _x;
originalY = _y;

this is the problem! You have to assign the X and Y positions to the variables but right now you assign the variables to the X and Y positions!
so it should be

_x = originalX;
_y = originalY;

cheers!

It doesn’t work because what you wrote is NOT easing.

This line doesn’t make sense anymore:

originalX += (endX-originalX)/speed;

There’s no easing, because you’re not manipulating the coordinates of the clip! (_x and _y)

pom :crazy:

Thanks Pom, but I’m still unsure as to what the code should look like? Any help would be great.

Thanks again

Kyle

I meant, if you don’t change _x and _y at some point, you won’t see much motion, right? And why don’t you use the first piece of code?

yeah, this is the kinda thing where you cant change it like you did. unless you did:


onClipEvent(load) {
_y=0;
_x=0;
OriganalY=_y;
OriganalX=_x;
}

ok wait, i just tested it and that wont work either, so you just have to stick with the original code. that is the only way i have ever seen it and the way i have always wrote it. if pom says you cant THEN LISTEN he knows his ActionScript.

*Originally posted by mdipi.com *
**if pom says you cant THEN LISTEN he knows his ActionScript. **
:stuck_out_tongue: I’m not saying you can’t do it that way, I’m just saying that you’re not moving the darn clip :beam:

I would make it like this:

onClipEvent (load) {
_x = 0
_y = 0
speed = 5;
}
onClipEvent (mouseUp) {
endX = _root._xmouse;
endY = _root._ymouse;
}
onClipEvent (enterFrame) {
originalX += (endX-originalX)/speed;
originalY += (endY-originalY)/speed;
_x = originalX;
_y = originalY;
}

:cool:

Yep Syko, that’s more like it.
But why create 2 variables? Waste of time, waste of memory… :ninja:

yeah! I think so too but he wanted 'em! :stuck_out_tongue:

Hey,

Thanks for the help, I guess my question now is why does the position of the movieclip have to start at 0,0, why not somewhere else? Cause this is what I was trying to do. I would have a button that was draggable and when you let go it would ease back to its initial position. I guess theres no way around it I have to have it start at 0,0. Thanks again for everyones help.

Kyle

onClipEvent (load) {
  _x = 50;
  _y = 200;
  speed = 5;
}
onClipEvent (mouseDown) {
  endX = _root._xmouse;
  endY = _root._ymouse;
}
onClipEvent (enterFrame) {
  _x += (endX-_x)/speed;
  _y += (endY-_y)/speed;
}

*Originally posted by ilyaslamasse *
**

onClipEvent (load) {
  _x = 50;
  _y = 200;
  speed = 5;
}
onClipEvent (mouseDown) {
  endX = _root._xmouse;
  endY = _root._ymouse;
}
onClipEvent (enterFrame) {
  _x += (endX-_x)/speed;
  _y += (endY-_y)/speed;
}

**

in other words it does not have to start at 0! :stuck_out_tongue: