Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
impaler

moveSelectionTo() ?

Recommended Posts

I was wanting to create a button that would set the location of an selection to the centre of the stage or parent.

To send an item to the top left I can see we can just mc1.x = mc1.y = 0; and moveSelection(0,0); updates everything.

 

How could we approach using the selection itself and using it's real width and height to find the center right etc of the stage or parent?

I have seen moveSelection() but this is relative to the selection's current position, how would we write a moveSelectionTo() ?

 

Thankyou, I am very much enjoying the wonderful work done here in GreenSock.

Link to comment
Share on other sites

Glad to hear you're enjoying it.

 

You could use the getSelectionBounds() method to figure out the position and width/height of the selection.

 

Also, you can directly move the targetObjects if you prefer and then just call updateSelection() to make sure TransformManager updates the selection box and handles.

Link to comment
Share on other sites

thank greensock this seems to be working so far;

 

           var selection_rect:Rectangle = _manager.getSelectionBounds();

           if ( selection_rect ) {

               var xms:Number = stage.stageWidth*.5 - selection_rect.width*.5;
               var yms:Number =  stage.stageHeight*.5 - selection_rect.height*.5;

               var xm:Number = 0 - ( selection_rect.x - xms);
               var ym:Number = 0 - ( selection_rect.y - yms);

               _manager.moveSelection(xm,ym);

           }

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.

×