Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-31-2011, 05:47 AM   #1
Registered User
Join Date: Oct 2011
Posts: 1
Default Transformation matrix reset

I use transform.matrix.
I create dynamically several objects. Than place them on scene (X Y) and apply transformatiom matrix to them, to rotate and scale object via it`s central point.

	for (var i:Number=1; i<6; i++) {
		OOK_Matrix[i] = OOK_Movie[i].transform.matrix;
		var pGlobal:Point = OOK_Movie[i].localToGlobal(new Point(OOK_Movie[i].width/2, OOK_Movie[i].height/2));
		OOK_Points[i] = OOK_Movie[i].parent.globalToLocal(pGlobal);
All works grate. But I have follow problem:
I need to change object position on screen. I set new X and Y. Objects moved to new place. All ok. But next operations with rotate and scale works some strange, not around it`s central point.

For example rotation I do by next code:

rotateMatrixMethodsOnly(OOK_Movie[i],Angle,OOK_Matrix[i], OOK_Points[i]);

function rotateMatrixMethodsOnly( obj:DisplayObject, angle:Number, mmtr:Matrix, pRotate_:Point ):void
	var rad:Number = angle * (Math.PI / 180);
	mmtr.translate( -pRotate_.tx, -pRotate_.ty );
	mmtr.rotate( rad );
	mmtr.translate( pRotate_.tx, pRotate_.ty );
	obj.transform.matrix = mmtr;
lexxvlad is offline   Reply With Quote
Old 10-31-2011, 08:47 AM   #2
Senior Member
Join Date: Mar 2009
Location: Islamabad, Pakistan
Posts: 207
Send a message via Skype™ to OmerHassan

All transformations are applied relative to the registration point. If your display object's registration point is at its top-left corner then that's the point about which it will rotate.

You can either set the registration point to your object's center by moving its contents along x by width/2 and along y by height/2, or you can rotate it about its current registration point and then translate it back to its original position.
OmerHassan is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:51 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.