0

I have an item renderer for a grid that has a fairly basic updateDisplayList function:

override protected function updateDisplayList( w : Number, h : Number ) : void
{
    super.updateDisplayList( w, h );

    var labelWidth : Number = Math.min( _labelDisplay.measuredWidth, w );
    var labelHeight : Number = Math.min( _labelDisplay.measuredHeight, h );

    _labelDisplay.setActualSize( labelWidth, labelHeight );

    var labelX : Number = ( w - _labelDisplay.width ) / 2;
    var labelY : Number = ( h - _labelDisplay.height ) / 2;

    _labelDisplay.move( labelX, labelY );

    //this is just for debugging
    graphics.clear();
    graphics.beginFill( 0xFF0000, 0.5 );
    graphics.drawRect( labelX, labelY, labelWidth, labelHeight );
    graphics.endFill();
}

where _labelDisplay is a spark label. When I scroll the grid (this is a cuatom grid, not mx:Grid or AndvancedDataGrid) when new rows appear at the bottom of the grid updateDisplayList is called and the code to re-draw the background and move / resize the label executes.

The problem is that these chanegs are not reflected in the view. The text is mis-aligned as a label that used to display a large string now displays a short string so the measuredWidth has changed.

The next time I scroll the renders update to look like they should - but updateDisplayList is NOT called here (on the renderes). All that happens is that the renderers are re-positioned in the grid. Both the background and the label are displayed incorrectly initially so it's not just the label mis-behaving.

Anyone got any idea why this is happening?

Thanks

Roaders
  • 4,373
  • 8
  • 50
  • 71
  • Showing us your updateDisplayList() code will not help us figure out why that method is not being called. You'll have to provide more. What component are you extending? How do the renderer and grid work together? – JeffryHouser Oct 14 '10 at 13:05
  • Thanks for the response. I am not asking why it is not called - I don't want it to be called more than once. I am asking why the updates applied by the updateDisplayList function are not visible until the next render takes place. – Roaders Oct 14 '10 at 13:06

1 Answers1

0

Just a guess, but does this make any difference?

override protected function updateDisplayList( w : Number, h : Number ) : void
{
    var labelWidth : Number = Math.min( _labelDisplay.measuredWidth, w );
    var labelHeight : Number = Math.min( _labelDisplay.measuredHeight, h );

    _labelDisplay.setActualSize( labelWidth, labelHeight );

    var labelX : Number = ( w - _labelDisplay.width ) / 2;
    var labelY : Number = ( h - _labelDisplay.height ) / 2;

    _labelDisplay.move( labelX, labelY );

   super.updateDisplayList( w, h ); // Call updateDisplayList after moving / resizing _labelDisplay
}
Marty Pitt
  • 28,822
  • 36
  • 122
  • 195