|
-
[RESOLVED] TransformationPoint? How do I use this?
I have created a Sprite object (a simple rectangle). I would like to set the transoformation point so that it is set to the middle of my Sprite object. I need this so that when I rotate it, it will rotate from the center rather than the top-left corner.
Solutions? Probably simple?
(*Just learning 3.0 - much better than 2.0)
-
Senior Member
You cannot set just simply like that. You need to use the Animator class, which is basically xml. There is a property called transformationPoint. Scroll to the bottom:
http://www.adobe.com/devnet/flash/qu...nal_files_as3/
- The right of the People to create Flash movies shall not be infringed. -
-
Shouldn't it be that easy tho? LOL!
Pivoting an object from a specific reference point is something pretty basic. Sounds like I may have to create a custom class.
If anyone knows an easier way... please let me know.
-
Senior Member
PHP Code:
var myspr=new Sprite();
myspr.x=100;
myspr.y=100;
addChild (myspr);
var point:Point=new Point(myspr.x+myspr.width/2, myspr.y+myspr.height/2);
rotateAroundCenter(myspr,45);
function rotateAroundCenter (ob:*, angleDegrees) {
var m:Matrix=ob.transform.matrix;
m.tx -= point.x;
m.ty -= point.y;
m.rotate (angleDegrees*(Math.PI/180));
m.tx += point.x;
m.ty += point.y;
ob.transform.matrix=m;
}
-
See... now that's what I'm talking about.
Thank you very, very much Tonypa!
-
Senior Member
I once made a workaround for flash 8. Here is the conversion:
PHP Code:
var container:MovieClip = new MovieClip();
container.x = 200;
container.y = 200;
addChild(container);
var conChild:A = new A();
conChild.name = "conChild";
container.addChild(conChild);
conChild.x = -container.width/2;
conChild.y = -container.height/2;
container.addEventListener(Event.ENTER_FRAME, rotate);
function rotate(e:Event)
{
e.target.rotation += 10;
}
- The right of the People to create Flash movies shall not be infringed. -
-
Senior Member
Yep, I used similar workaround too in earlier versions 
Also wish to point that if you use Flash CS3, it comes with MatrixTransform class which has 2 methods to rotate around chosen point.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|