Jump to content
Search Community

Scaling the FlexTransformManager

khalidmbajwa test
Moderator Tag

Recommended Posts

Hey,

 

Firstly i wanted to say what an absolutely terrific library this is, it just works. Amazing !

Now, i have this Flex Container (BorderContainer to be exact) into which i add FlexTransformManager. The thing is that that the applications is re sizable, and scaling seems to adjust the bounds in which objects can be manipulated and not the scale. My requirement is such that the TransformManager container should scale automatically, including its children much like a movieclip does. How do i go about it ?

 

Khalid

Link to comment
Share on other sites

Nevermind,i have found a way. For anyone who is interested, basically in the resize even for the parent container that houses the FlexTransformManager, i iterate over all the items managed by the FlexTransformManager and use their transform matrix to scale them about the upper left corner (0,0). Here is a snippet.

private function resized(e:Event)

{

if(_manager!=null)

{

var scaleFactors:Point=new Point(this.width/_lastCoordinates.x,this.height/_lastCoordinates.y);

_manager.width=this.width;

_manager.height=this.height;

 

var i:Number=0;

for(i=0;i<=_manager.numChildren-1;i++)

{

var item:VisualItem=VisualItem(_manager.getChildAt(i));

var m:Matrix = item.transform.matrix;

var oldValues:Point=new Point(m.tx,m.ty);

m.translate(0, 0);

m.scale( scaleFactors.x, scaleFactors.y);

item.transform.matrix = m;

m.translate(oldValues.x,oldValues.y);

}

 

_lastCoordinates.x=this.width;

_lastCoordinates.y=this.height;

}

 

 

 

}

Love how TransformManager class plays well with manually scaled items. Super !

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...