View Full Version : easing problem
iceman
January 12th, 2003, 03:48 PM
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
andr.in
January 12th, 2003, 03:57 PM
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!
pom
January 12th, 2003, 05:17 PM
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:
iceman
January 12th, 2003, 05:55 PM
Thanks Pom, but I'm still unsure as to what the code should look like? Any help would be great.
Thanks again
Kyle
pom
January 12th, 2003, 07:18 PM
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?
mdipi
January 12th, 2003, 08:42 PM
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.
pom
January 13th, 2003, 06:11 AM
Originally posted by mdipi.com
if pom says you cant THEN LISTEN he knows his ActionScript. :P I'm not saying you can't do it that way, I'm just saying that you're not moving the darn clip :beam:
andr.in
January 13th, 2003, 08:04 AM
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:
pom
January 13th, 2003, 10:17 AM
Yep Syko, that's more like it.
But why create 2 variables? Waste of time, waste of memory... :ninja:
andr.in
January 13th, 2003, 01:05 PM
yeah! I think so too but he wanted 'em! :P
iceman
January 13th, 2003, 01:13 PM
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
pom
January 13th, 2003, 01:46 PM
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;
}
andr.in
January 13th, 2003, 02:08 PM
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! :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.