because your layed out width is greater than your measuredWidth.  Same
for height.
 
Let's say the label is 100 wide and you have a two pixel border.
measuredWidth will be 104.  If you're given a width other than 104 in
updateDisplayList, you'll move the label a bit and now measuredWidth
will report a different number.
 
Also, it is recommended that you use getExplicitOrMeasuredWidth() in
measure() because the label hasn't been layed out yet so it doesn't have
a valid width.

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Giles Roadnight
Sent: Tuesday, May 20, 2008 1:08 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Measure and UpdateDisplayList called continuously



Hi All

I'm writing an item renderer based on a Canvas. I have the following
methods (the canvas just has a label as a child)

override protected function measure():void
{
    super.measure();
    
    var metrics:EdgeMetrics = viewMetricsAndPadding;
    
    measuredWidth = _label.width + metrics.left + metrics.right;
    measuredHeight = _label.height + metrics.top + metrics.bottom;
}

override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    
    var metrics:EdgeMetrics = viewMetricsAndPadding;
    
    _label.x =
(unscaledWidth-(_label.width+metrics.left+metrics.right))/2;
    _label.y =
(unscaledHeight-(_label.height+metrics.top+metrics.bottom))/2;
}

What's wrong with these methods? why do they get continually called? At
the moment this hangs the application.

If I add a bit of padding it works fine.

_label.x and _label.y are both set to 0 in the above case.

-- 
Giles Roadnight
http://giles.roadnight.name <http://giles.roadnight.name>  

 

Reply via email to