Darron Schall's class didn't work out for me since mixing prototypes
gave me a lot of syntax errors. Here's the code I built from Robert
Penner's Vector3D.rotateZ() method. I hope someone finds it usefull.

var mc:MovieClip; // mc on stage
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 = 0;

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

function rotate(angle) {
        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) {
        return Math.sin (angle * (Math.PI / 180));
}

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


2006/2/13, Bart Wttewaall <[EMAIL PROTECTED]>:
> exactly! thanks a lot!
> I mustn't have used the right keywords in my search ;)
>
>
> 2006/2/13, Adrian Lynch <[EMAIL PROTECTED]>:
> > It was on Flashcoders or Flashnewbie a few days ago.
> >
> > http://www.darronschall.com/weblog/archives/000054.cfm
> >
> > Is that the link you were after?
> >
> > Adrian
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] Behalf Of Bart
> > Wttewaall
> > Sent: 13 February 2006 17:31
> > To: Flashcoders mailing list
> > Subject: [Flashcoders] Rotating a mc around a custom pivotpoint
> >
> >
> > Hi list,
> >
> > I'm looking for a piece of math to rotate a mc around a pivotpoint,
> > other then its original. I've seen the math before in a demo, on some
> > blog perhaps, but can't seem to find it again. I made some attempts to
> > write it myself, but my math is as rusty as a german submarine.
> >
> > Much obliged,
> > Bart
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > 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
> >
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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