0 Replies Latest reply on Dec 20, 2013 8:55 AM by afukada

    how to center a VGroup when scaled

    afukada

      I'm using the following code to center a VGroup, and it works when the scaling factor is 1.

      img1.JPG

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application 
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:fx="http://ns.adobe.com/mxml/2009"
                     creationComplete="this.scaleX=this.scaleY=1;"
                   >
      
          <s:Group width="100%" height="100%">
              <s:VGroup width="300" height="200" horizontalCenter="0" verticalCenter="0">
                  <s:Rect width="100%" height="100%">
                      <s:fill>
                          <s:SolidColor color="gray" />
                      </s:fill>
                  </s:Rect>
              </s:VGroup>
          </s:Group>
      </s:Application>
      

       

      However, when the scaling factor is set to 1.5, for example, the output is messed up. The VGroup is no longer centered. It's actually gone off the screen. I think what happened is that the outer Group was blown up by 1.5 (of which we can only see a portion) and the VGroup is centered in that blown-up space. How can I get the VGroup to be 1.5 times larger and centered on the screen?

      img2.JPG