# onPress problem; aim

**URL:** <https://forum.kirupa.com/t/onpress-problem-aim/179822>\
**Category:** flash\
**Created:** [February 23, 2006, 7:29am UTC](https://forum.kirupa.com/t/onpress-problem-aim/179822 "2006-02-23T07:29:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fm47](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@fm47](https://forum.kirupa.com/u/fm47)\
**Post date:** [February 23, 2006, 7:29am UTC](https://forum.kirupa.com/t/onpress-problem-aim/179822/1 "2006-02-23T07:29:45Z")

</div>

I have a gun that, when I use onPress, rotates the gun that makes it look like it’s recoiling back. But the problem is that when it rotates, it rotates itself off the click of the mouse .

i have

\_x = \_root.\_xmouse;  
\_y = \_root.\_ymouse;

and

onPress = function () {  
\_rotation -= 80;  
}

if (\_rotation \< 0) {  
\_rotation += 10;  
}

When it rotates, the shape of the gun falls off the mouse… how do I fix that?

also, I would like a line that beams between a gun and an object… how would I go about doing that?

I like to try things before asking people and the only concept I have is find the distance between the gun and the object then draw a line or change the length of a line to the distance between the gun and and the object.

so maybe like…  
gunPos = gun.\_x+\_width/2;  
objPos = target.\_x-\_width/2;

I guess this would tread into the hitBox area, huh? If the gun was to be rotated… ugh i’m confused
