This content has been marked as final. Show 4 replies
OK, I found a way to access my Child :
var MyChild:UIComponent = UIComponent(DayBox.getChildAt(1)); // using import mx.core.UIComponent;
But it seems that an object with a percentHeight has no height property...
Does anyone know if it's possible to read the height property of a percent height based object ?
Try using the measuredHeight property to get a pixel value of the height.
Thanks for your answer.
I try measuredHeight property but the value is set to 0 and my object has a real height that is non zero.
My Child is added by AS... May be that's why ???
Hmm... a few questions
What does the height property return?
What is the DayBox's height property?
At what point are you trying to read the height property? I ask this because, Flex will need to run its layout/positioning code before it can tell you what the rendered height will be.
This works, but it is post render.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
private function init():void
for(var i:int=0; i<7; i++)
trace('adding new canvas');
var Can:Canvas = new Canvas();
Can.width = DayBox.width;
Can.percentHeight = 50;
Can.width = 40;
private function doitClick():void
<mx:HBox id="DayBox" height="50%" borderStyle="solid" borderColor="#ff0080" left="20" right="20" top="40">
<mx:Label id="mylabel" x="81" y="12" text="click button"/>
<mx:Button click="doitClick()" x="20" y="10" label="Do it"/>
Note: I'm setting the width and background color, just so I can see them.