Flex Builder UI returns incorrect height for the UIComponent
Issue
After you update an Adobe Flex Builder UI component to increase the height, Flex Builder may not return the correct height.
After running the example below, the height returned by Flex Builder for the UIComponent 'myContainer' does not truly reflect the new height.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[ private function init():void { trace(myContainer.height);
filterBy.text="ssdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdas";
trace(myContainer.height);
} ]]>
</mx:Script> <mx:HBox verticalScrollPolicy="off" id="myContainer">
<mx:Text color="white" id="filterBy" updateComplete="handleUpdateComplete(event)"
</mx:HBox>
</mx:Application>
Solution
To resolve this issue, use the updateComplete attribute to obtain the correct height.
For example:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()">
<mx:Script> <![CDATA[ private function init():void { trace(myContainer.height);
filterBy.text="ssdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdas";
trace(myContainer.height); }
private function handleUpdateComplete(e:Event):void { trace(myContainer.height); }
]]>
</mx:Script>
<mx:HBox verticalScrollPolicy="off" id="myContainer" >
<mx:Text color="white" id="filterBy" updateComplete="handleUpdateComplete(event)"
</mx:HBox>
</mx:Application>
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
