3 Replies Latest reply on Sep 12, 2009 11:47 PM by viatropos

    getBounds() and getRect() returning wrong size

    viatropos Level 1



      I've never used those two methods before, but when I do the following, I get unexpected/wrong sizes:



      <s:Button id="button" x="200" width="100" height="100" />

      <s:Panel id="panel" x="200" width="100" height="100" rotation="45"/>

      <s:Button id="button2" x="400" width="100" height="100" />

      <s:Button id="button3" x="400" width="100" height="100" rotation="45" />


      function applicationComplete(event:FlexEvent)


           var rect:Rectangle = panel.getRect(this);

           button.width = rect.width;

           button.height = rect.height;


           rect = button3.getRect(this.stage);

           button2.width = rect.width;

           button2.height = rect.height;



      If I use the "getBounds()" method, same thing:  The button is almost the header's height larger than the rotated panel.  If I use two buttons, the rect is almost the size of the other rotated button, but there's still a little gap.  I've attached an image of what it looks like.


      What am I doing wrong/how can I get the bounds of the rotated object so the rectangle perfectly surrounds it?