I took a rotateZ method from Robert Penner's Vector3D class and added
a pivotpoint to the formula. It works pretty well as a dynamic
registrationpoint :)

var mc:MovieClip;
var position:Object = {x:mc._x, y:mc._y};
var pivot:Object = {x:position.x+mc._width/2, y:position.y+mc._height/2};
var angle:Number = 0;

onEnterFrame = function():Void {
        angle += 5;
        rotate(angle);
}

function rotate(angle:Number):Void {
        var ca:Number = cosD(angle);
        var sa:Number = sinD(angle);
        var x = (position.x - pivot.x) * ca - (position.y - pivot.y) * sa;
        var y = (position.x - pivot.x) * sa + (position.y - pivot.y) * ca;
        
        mc._x = pivot.x + x;
        mc._y = pivot.y + y;
        mc._rotation = angle %= 360;
}

function sinD(angle:Number):Number {
        return Math.sin (angle * (Math.PI / 180));
}

function cosD(angle:Number):Number {
        return Math.cos (angle * (Math.PI / 180));
}

2006/6/1, grimmwerks <[EMAIL PROTECTED]>:
That'll do it! Thanks.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to