Ok, i have a function that is moving a mc in a spiral.
Here is the code:
right now i have origin_1_x set to 300, so it should act the same as if i had 300 hardcoded (which is currently commented out).Code://rotz(dot, 300, 300, .1, 1.004); rotz(dot, origin_1_x, origin_1_y, .1, 1.004); function rotz(who,cx,cy,spd,exp){ trace("first x "+who._x); trace("cx "+cx); dx = (who._x -cx) * exp; dy = (who._y -cy) * exp; trace("dy "+dy); trace("equation " +(cx+((Math.cos(spd) * dx -(Math.sin(spd) * dy))))); who._x = cx+((Math.cos(spd) * dx -(Math.sin(spd) * dy))); who._y = cy+((Math.sin(spd) * dx +(Math.cos(spd) * dy))); trace("second x "+who._x); }
When I hard code 300 in there it works great. but since i will let the user decide what the origin will be, i want to pass a variable instead.
currently, when i hardcode 300 in this is my trace output:
first x 246.95
cx 300
dy -66.3644
equation 253.629273943845
second x 253.6
However, when i pass the variable instead, this is my output
first x 246.95
cx 300
dy -66.3644
equation 300-46.3707260561545
second x 246.95
x gets passed in just fine (as cx is 300), however, the assignment of changing the value of who._x doesn't work at all. and the equation brings back a different result...
anyone else encounter something like this before?
any ideas?
thanks
ty




Reply With Quote