# Moving target after event

**URL:** https://forum.kirupa.com/t/moving-target-after-event/291494
**Category:** Uncategorized
**Created:** [June 30, 2009, 2:24pm UTC](https://forum.kirupa.com/t/moving-target-after-event/291494 "2009-06-30T14:24:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Yve](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@Yve](https://forum.kirupa.com/u/Yve)
#### Post date: [June 30, 2009, 2:24pm UTC](https://forum.kirupa.com/t/moving-target-after-event/291494/1 "2009-06-30T14:24:20Z")

</div>

Hi i am making a game where the user places a tile on a target, then the target needs to move across the stage ready for the next tile to be placed.  
here is the code i am using:

var Xpos:Number;  
var Ypos:Number;

heatLight\_mc.onPress = function() {  
this.startDrag(true);  
Xpos = this.\_x;  
Ypos = this.\_y;  
}  
heatLight\_mc.onRelease = function() {  
this.stopDrag();

if (heatLight\_mc.hitTest(target2\_mc)) {  
stop();

}else if (heatLight\_mc.hitTest(target1\_mc)) {

target1\_mc.onEnterFrame = function() {  
this.\_x += 2; //here is where i need to stop it at X coordinate??

};  
}else{  
heatLight\_mc.\_x = Xpos;  
heatLight\_mc.\_y = Ypos;  
}  
};

This makes the target move across the stage, but I cannot get it to stop at a X coordinate.  
can anyone help please, thanks
