Skip to main content
March 31, 2010
Answered

Way to add Matrix points to a movieclip

  • March 31, 2010
  • 1 reply
  • 618 views

I'm trying to use the MatrixTransform class to RotateAroundInternalPoint but it requires that the object I'm trying to rotate has matrix points defined. My question is, is there a way to add Matrix points to a non Shape object so I can rotate it, or is there another class that is used to rotate movie clips around internal points?

This topic has been closed for replies.
Correct answer kglad

you can use the following function to rotate any displayobject around any point:

usage:

rotateF(yourdisplayobject,whateverangle,whateverXrelativetoyourdisplayobject,whateverrelativeY);


/////////////////////////// don't change below //////////////////////


function rotateF(dobj:DisplayObject,angle:Number,x:Number,y:Number):void {
    var p:Sprite=new Sprite();
    p.x = dobj.x+x;
    p.y = dobj.y+y;
    dobj.x=-x;
    dobj.y=-y;
    p.addChild(dobj);
    p.rotation=angle;
    addChild(p);
    var mat:Matrix = dobj.transform.concatenatedMatrix;
    addChild(dobj);
    p=null;
    dobj.transform.matrix = mat;
}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 31, 2010

you can use the following function to rotate any displayobject around any point:

usage:

rotateF(yourdisplayobject,whateverangle,whateverXrelativetoyourdisplayobject,whateverrelativeY);


/////////////////////////// don't change below //////////////////////


function rotateF(dobj:DisplayObject,angle:Number,x:Number,y:Number):void {
    var p:Sprite=new Sprite();
    p.x = dobj.x+x;
    p.y = dobj.y+y;
    dobj.x=-x;
    dobj.y=-y;
    p.addChild(dobj);
    p.rotation=angle;
    addChild(p);
    var mat:Matrix = dobj.transform.concatenatedMatrix;
    addChild(dobj);
    p=null;
    dobj.transform.matrix = mat;
}

March 31, 2010

makes sense, appreciate it

kglad
Community Expert
Community Expert
March 31, 2010

you're welcome.