can you not calculate the new rotation based on the mouse position and the rotate by the difference with the current rotation on your rectangle?
function rotateObject( event:Event ):void
var newRot:Number = Math.atan(mouseX/mouseY);
var rotationDelta:Number = myRectangle.rotation - newRotation
m.tx -= point.x;
m.ty -= point.y;
m.tx += point.x;
m.ty += point.y;
Any reason you're not simply setting the registration point to the place you want to rotate it, the bottom left?
Meaning create the rectangle in a display object (Sprite, etc) so you can just set its y position to rectangle.y -= rectangle.height;. Rotate the sprite and it'll, with much less cpu, rotate the rectangle on its bottom left corner.
See in the beginning i thought that i could simply move the registration point to one of the display object's corners, but when i do that and then rotate the object with code it still rotates around its center.... I would love to be able to make it that simple, I wonder why that way isn't working for me. I tried doing what you suggested Sinious, it moved my rectangle up higher but still rotates around its origin.(center). Using _spoboyle code didnt seem to help, the rectangle spins out of control like crazy... All I need is a rectangle that rotates (to follow the mouse position) but the rectangle needs to rotate around one of its corners rather than its center. You guys could probly just make your own code in a minute, im a noob
Sure.. make a new AS3 document, paste this into frame 1, run:
// container, I'll use graphics and draw
// directly into it
var container:Sprite = new Sprite();
// draw rectangle, pushing up on the y axis
container.graphics.drawRect(0,-100,100,100); // see the -100 on y axis?
// position it in the center of the stage
container.x = stage.stageWidth / 2;
container.y = stage.stageHeight / 2;
// start rotating baby
container.rotation += 3;
Sorry its been a few days, thank you so much for that code, I think it will help me get the desired result im looking for, thank you again.