# Enemy Arm Rotation Problem, fla & swf inside

**URL:** <https://forum.kirupa.com/t/enemy-arm-rotation-problem-fla-swf-inside/227441>\
**Category:** programming\
**Created:** [May 30, 2007, 11:03am UTC](https://forum.kirupa.com/t/enemy-arm-rotation-problem-fla-swf-inside/227441 "2007-05-30T11:03:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CallMeJack](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/callmejack/32/3683_2.png) [@CallMeJack](https://forum.kirupa.com/u/CallMeJack)\
**Post date:** [May 30, 2007, 11:03am UTC](https://forum.kirupa.com/t/enemy-arm-rotation-problem-fla-swf-inside/227441/1 "2007-05-30T11:03:21Z")

</div>

Hello everyone,  
right now I have a stick figure that walks towards the mouse cursor. I want his arm to rotate so that he points to the cursor. I have an UpperBody\_mc and inside of it I have the arm that needs to rotate. I am accessing it by doing this UpperBody\_mc.Arm\_mc.\_rotation. The rotation code isn’t the problem I believe its just how I am accessing the arm or something…

heres all the code

```auto
speed = 1
onEnterFrame = function()
{
 Mx = _root._xmouse;
 My = _root._ymouse;
 CharX = (UpperBody_mc._width/2)+UpperBody_mc._x;
 if(Mx-20 < CharX && Mx+40 > CharX)
 {
  Legs_mc.stop();
 }
 else if(Mx-20 > CharX)
 {
  if(UpperBody_mc._xscale < 0)
  {
   UpperBody_mc._xscale *= -1;
   Legs_mc._x -= 5;
   Legs_mc._xscale *= -1;
  }
  UpperBody_mc._x += speed;
  Legs_mc.play();
  Legs_mc._x += speed;
  //Arm movement
 }
 else
 {
  if(UpperBody_mc._xscale > 0)
  {
   UpperBody_mc._xscale *= -1;
   Legs_mc._xscale *= -1;
   Legs_mc._x += 5;
  }
  UpperBody_mc._x -= speed;
  Legs_mc.play();
  Legs_mc._x -= speed;
 }
}
onMouseMove = function()
{
 adjside =_root._xmouse - _root.UpperBody_mc.Arm_mc._x;
 oppside = -1*(_root._ymouse - _root.UpperBody_mc.Arm_mc._y); 
 angle = Math.atan2(oppside, adjside); // in radians
 angle = Math.round(angle/Math.PI*180); // convert to degrees
 _root.UpperBody_mc.Arm_mc._rotation = -1*(angle);
} 

```

heres the swf. [http://img406.imageshack.us/my.php?image=testguyfc1.swf](http://img406.imageshack.us/my.php?image=testguyfc1.swf)  
heres the fla. [[COLOR=#0000ff]http://download.yousendit.com/C9D1DE39116F4832[/COLOR]](http://download.yousendit.com/C9D1DE39116F4832)
