2 Replies Latest reply on Feb 21, 2011 5:44 AM by miguel8312

    Get x,y position

    Flex Rock Level 1

      Hi,

            I have a vbox. I need to get the x,y position of the vbox. Beacuse i need to apply this x,y postion to another box based on condition.

       

      Regards,

      Jayagopal.

        • 1. Re: Get x,y position
          miguel8312 Level 3

          well if you have a vbox like such

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
           <mx:Script>
            <![CDATA[
             [Bindable]
             public var _x:Number;
             [Bindable]
             public var _y:Number;
             public function getVboxCoordinates():void{
              
              _x = myBox.x;
              _y = myBox.y; 
              
              
              
              
              
             }
             
            ]]>
           </mx:Script>
           
           
           
           
          <mx:VBox id="myBox">
          <mx:Button id="runFunc" click="getVboxCoordinates();"/> 
          <mx:Label text="{_x+ ':' +_y}"   />
          </mx:VBox> 
          </mx:Application>
          
          • 2. Re: Get x,y position
            Yozef0 Level 1

            <mx:VBox id="myVBox" >

                 <mx:Spacer />

                 <comp:stuff2 />

            </mx:VBox>

             

            <mx:VBox id="myVBox2" x="{myVBox.x}" y="{myVBox.y}">

                 <comp:stuff1 />

                 <comp:stuff2 />

            </mx:VBox>

             

             

            If you've got your self a condition: x="{myVBox.x < 100?150:75}"

             

            This syntax has the following explanation: if myVBox.x < 100, if true the x of myVBox2 is something an number(or int) of course, if not the other (also an int or number). The { } makes the properties in them bindable... meaning they'll update once they change.

             

            Also, reducing as much variables instantiated in your code is more effective.

            1 person found this helpful