You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Tintin <19...@googlemail.com> on 2014/07/11 15:44:20 UTC
Scale a Component About a Defined Point
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
--
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.
Re: Scale a Component About a Defined Point
Posted by Tintin <19...@googlemail.com>.
I wasn't aware of TransformAround, thanks. I will read up on it and see if
would help.
--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Scale-a-Component-About-a-Defined-Point-tp7233p7253.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.
Re: Scale a Component About a Defined Point
Posted by Deepak MS <me...@gmail.com>.
http://www.slideshare.net/mobile/danielwanja/building-ipad-apps-with-flex-360flex
In that, after about 60 slides, there is a gesture specific example, in
which component.tranformAround(...specific point) is used. See if that
helps.
On 11 Jul 2014 19:14, "Tintin" <19...@googlemail.com> 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
>
>
>
> --
> 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.
>
Re: Scale a Component About a Defined Point
Posted by Tintin <19...@googlemail.com>.
Thank you for your suggested code. I'll have a play with it and see if it
does what I want.
--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Scale-a-Component-About-a-Defined-Point-tp7233p7252.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.
Re: Scale a Component About a Defined Point
Posted by OmPrakash Muppirala <bi...@gmail.com>.
On Fri, Jul 11, 2014 at 6:44 AM, Tintin <19...@googlemail.com>
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.
>