On Fri, Jul 11, 2014 at 6:44 AM, Tintin <[email protected]>
wrote:
> Hello
>
> I'm sure this should be simple, but I can't see it. I want to scale a Spark
> Group (and its content within) about a specific point, not its centre.
> Currently to achieve what I want I have to set the Group.ScaleX and
> Group.ScaleY and then calculate the offset required to keep my centre point
> fixed and then apply these new Group.X and Group.Y values.
>
> Is there a way to set the origin point about which you want to scale
> please?
>
> Regards
>
> Chris
>
>
I use this code to rotate a displayobject around a point:
private var rotationMatrix:Matrix;
private function rotate(obj:DisplayObject, angle:Number,
aroundX:Number, aroundY:Number):void
{
rotationMatrix = new Matrix();
rotationMatrix.translate(-aroundX,-aroundY);
rotationMatrix.rotate(Math.PI*angle/180);
rotationMatrix.translate(aroundX,aroundY);
obj.transform.matrix = rotationMatrix;
}
I haven't tried scaling with this method, but maybe you can just modify it
for scaling like this:
private var scaleMatrix:Matrix;
private function rotate(obj:DisplayObject, scaleX:Number,
scaleY:Number, aroundX:Number, aroundY:Number):void
{
scaleMatrix= new Matrix();
scaleMatrix.translate(-aroundX,-aroundY);
scaleMatrix.scale(scaleX, scaleY);
scaleMatrix.translate(aroundX,aroundY);
obj.transform.matrix = scaleMatrix;
}
I might be completely off base with my math here, but please do try and see
if it works.
Thanks,
Om
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/Scale-a-Component-About-a-Defined-Point-tp7233.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>