2 Replies Latest reply on Apr 22, 2010 10:16 AM by Flex harUI

    Event handler for an HBox

    SiHoop Level 1

      I'm trying to calculate the width of an HBox after a component has been loaded into it. What event handler will tell me that an object has been added to an HBox?

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   applicationComplete="init()">
          <mx:Script>
        <![CDATA[
      public function init():void{
          for(var i:int=0; i<5;i++){
              var panel1:MainPanel=new MainPanel;
              panel1.x=i*120;
              hbox.addEventListener(XXXXXXXXXXXXXXXXX, handlePanel1Load)
              hbox.addChild(panel1)
          }

      }
      public function handlePanel1Load(e:Event):void{
          trace("loaded="+hbox.width)
      }
        ]]>
      </mx:Script>
            <mx:Canvas id="hbox"  borderColor="0xffff00"  backgroundColor="0xdddddd" horizontalCenter="0" verticalCenter="0"  borderStyle="solid"/>
      </mx:Application>