Skip navigation
Currently Being Moderated

how to center a VGroup when scaled

Dec 20, 2013 8:55 AM

Tags: #scaling #center #4.6 #vgroup

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

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points