3 Replies Latest reply on May 9, 2010 7:14 AM by jerry98225

    Center label instance inside VGroup in Flex

    jerry98225 Level 1

      Hi all I am trying to center my labels below my image inside my VGroup.

      The labels are align to left now and it seems like HorizontalAlign is not working on spark component.

      Anyone knows how to fix it? Thanks a lot.



      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                    
      xmlns:s="library://ns.adobe.com/flex/spark"
                    
      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
         
      <fx:Declarations>
             
      <!-- Place non-visual elements (e.g., services, value objects) here -->
         
      </fx:Declarations>
         
      <s:VGroup width="800">

             
      <mx:Image source="images/big/city1.jpg"/>
             
      <s:Label text="test1" horizontalCenter="0" /> //doesn't work....:(
             
      <s:Label text="test2" />


         
      </s:VGroup>

      </s:Application>

        • 1. Re: Center label instance inside VGroup in Flex
          Gregory Lafrance Level 6

          horizontalAlign="center"

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"                
                         xmlns:s="library://ns.adobe.com/flex/spark"                
                         xmlns:mx="library://ns.adobe.com/flex/mx" 
                         minWidth="955" minHeight="600">    
            <fx:Declarations>        
            <!-- Place non-visual elements (e.g., services, value objects) here -->    
            </fx:Declarations>    
            <s:VGroup horizontalAlign="center" width="100%">        
              <s:Label text="test1"/> 
              <s:Label text="test2" />    
            </s:VGroup>
          </s:Application>
          

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex Training and Support Services

          • 2. Re: Center label instance inside VGroup in Flex
            David_F57 Level 5

            hi,

             

            You need to set both a width value and an alignment value in order to center to the image

             

                    <mx:Image id+"img" source="images/big/city1.jpg"/>
                   
            <s:Label text="test1" width="{img.width}" textAlign="center"/>

            David

            1 person found this helpful
            • 3. Re: Center label instance inside VGroup in Flex
              jerry98225 Level 1

              Thanks! Both of you gave the correct answer. I can only give one correct answer call here..

               

              I gave Greg since this is the second time he helps me and first one reply to me. You guys rocks!