# Moving an object

**URL:** <https://forum.kirupa.com/t/moving-an-object/198062>\
**Category:** Uncategorized\
**Created:** [August 22, 2006, 4:36am UTC](https://forum.kirupa.com/t/moving-an-object/198062 "2006-08-22T04:36:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daytonatkf](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@daytonatkf](https://forum.kirupa.com/u/daytonatkf)\
**Post date:** [August 22, 2006, 4:36am UTC](https://forum.kirupa.com/t/moving-an-object/198062/1 "2006-08-22T04:36:51Z")

</div>

\*\*ang = Math.atan2(targety-this.\_y, targetx-this.\_x);  
this.\_x += Math.cos(ang)_speed;  
this.\_y += Math.sin(ang)speed;_

**ang = Math.atan2(targety-this.\_y, targetx-this.\_x);**

**ang = Math.atan2(this.\_y-targety, this.\_x-targetx);**

i got this three scripts from this forum, but i doesnt work as what i want. i trying to implement an object that can move by it self with a (x,y) given. I try to use in a while loop, but i doesnt work and hang there which cause me to abort the script. Any guidelines for moving an object using action script (not by keyboard arrow keys), thanks for reply
