Argh! Rotating a MC to point at the mouse

  • endalpha
  • Born
  • Born
  • endalpha
  • Posts: 1
  • Loc: England

Post 3+ Months Ago

Ok, this has had me stumped. I know next to nothing in Actionscript, and I've been surfing looking for examples. Every script I have tried just doesn't move anything. So I was wondering if I could get you guys to help me.

I'll post what I have right now. I know there are some obvious mistakes, but it's just because I've been fiddling with brackets etc. to see if I can get it to work. So don't laugh at my ineptitude :?

onClipEvent(enterFrame){
_global.radiansToDegrees = function (radians)
{
return (radians/Math.PI) * 180;
}

MovieClip.prototype.rotateTowardsMouse = function () {
var point = {x:this._x, y:this._y};

this._parent.localToGlobal(point);

var deltaX = _root._xmouse - point.x;
var deltaY = _root._ymouse - point.y;

var rotationRadian = Math.atan2(deltaY, deltaX);

var rotationAngle = radiansToDegrees(rotationRadian); // See earlier function

this._rotation = rotationAngle;
}

Arm.onEnterFrame=rotateTowardsMouse;
}

Yeah, even I know a few of those brackets are completely randomly placed.

So, if anyone can help, it would be much appreciated.

If it makes a difference, this movie clip is pointing to the left and I want it to rotate at the right side.

Thanks in advance,
Another confused first-post newbie :oops:

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.