Here is the codes:
 
  override protected function updateDisplayList(unscaledWidth:Number, 
unscaledHeight:Number):void{
    super.updateDisplayList(unscaledWidth, unscaledHeight); 
    lal.setActualSize(unscaledWidth, unscaledHeight);
  }
  
  override protected function createChildren():void{
    super.createChildren();
   
    if( lal == null ){
      lal = new Label;
      lal.text = "Label";
      addChild(lal);
    }
  }
  
  override protected function measure():void{
    super.measure();
    measuredWidth = lal.getExplicitOrMeasuredWidth();
    measuredHeight = lal.getExplicitOrMeasuredHeight();
  }
 
I track the processing of these functions. The red code excuted before the 
green code. I thought the children actual size should be set before his 
parent container and then use the children's proterties to set his parent 
container.
I comment the green code.So There is nothing on the screen. 
The value of "lal.getExplicitOrMeasuredWidth/Height();" is as same as the 
"unscaledWidth/Height"
Flex already know before setting the Label's width and height. 
Why should the label be set up again ?
 

在2009-06-04,"Manish Jethani" <manish.jeth...@gmail.com> 写道:





On Wed, Jun 3, 2009 at 10:26 PM, Manish Jethani
<manish.jeth...@gmail.com> wrote:
> 2009/6/3 j2me_soul <j2me_s...@163.com>:

>>   override protected function measure():void{
>>    this.explicitMinWidth = this.explicitMinHeight = 50;
>>   }
>>  }
>
> Here you should set the meauredWidth, measuredHeight, and optionally
> measuredMinWidth and measuredMinHeight (they can be set to the same as
> measuredWidth and measuredHeight respectively).

I forgot to say how to do the measurement. Here's how I'd do it:

function measure():void
{
measuredWidth = lal.getExplicitOrMeasuredWidth();
measuredHeight = lal.getExplicitOrMeasuredHeight();
}

Manish


Reply via email to