Personally I have a huge preference for AS only itemrenderers however that
said, at first glance I would ask why are you adding a event listener when
the button has this built in?



<mx:Button click="onClick(event);" xmlns:mx="http://www.adobe.com/2006/mxml";
initialize="init();">

Take note of the (click="onClick(event);") above.

As for the updateDisplayList, I suggest you read up on what it’s for and
just how important it is…


jason


  -----Message d'origine-----
  De : [email protected] [mailto:[EMAIL PROTECTED] la
part de durnelln
  Envoyé : vendredi 16 mars 2007 11:22
  À : [email protected]
  Objet : [flexcoders] Datagrid Button Renderer Performance


  Hi all,

  I have a simple button renderer (below) which I use in my datagrids.
  All seemed fine but I now have four of these button renderers in each
  row of my datagrid(s) and performance starts to suffer when there are
  many rows on display at once (my app can easily have a hundred or
  more rows on display in various datagrids).

  I've noticed that when a row's data changes, the updateDisplayList
  function is called on every button renderer in that row. Does anyone
  know why this is or how I can stop it happening? The row data does
  not affect the visual appearance of the button so there is no need to
  redraw it every time the row data changes. I'm thinking this
  constant redrawing of the buttons might be the cause of the
  performance issues as I could quite easily have, say, 400 button
  renderers on screen at once and the row data changes quite frequently.

  Any ideas?

  This is my button renderer:

  <?xml version="1.0" encoding="utf-8"?>
  <mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"; initialize="init
  ();">
  <mx:Script>
  <![CDATA[
  import custom.DataGridButtonClickEvent;

  //action to request when button is clicked
  public var action:String;

  //a copy of the data passed in to send back
  if the button is clicked
  private var _data:Object;

  //listen for button click events
  private function init():void
  {
  this.addEventListener
  (MouseEvent.CLICK, onClick);
  }

  //called when grid data changes or scrolls -
  determine button enabled status
  override public function set data
  (value:Object):void
  {
  if (value != null)
  {
  _data = value;
  }
  }

  //local click handler to dispatch a custom
  event containing the requested action
  private function onClick(e:MouseEvent):void
  {
  //dispatch an event containing the
  row data and requested action
  if ((enabled) && (action))
  {
  dispatchEvent(new
  DataGridButtonClickEvent(_data, this.id, action, true, true));
  }
  }
  ]]>
  </mx:Script>
  </mx:Button>

  Thanks,

  Nick.



  

Reply via email to