/ Published in: ActionScript 3
**mostly used inside an onEnterFrame event handler
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var dx:Number = sprite.x - fixedX; var dy:Number = sprite.y - fixedY; var angle:Number = Math.atan2(dy, dx); var targetX:Number = fixedX + Math.cos(angle) * springLength; var targetY:Number = fixedX + Math.sin(angle) * springLength;