Overiding IGridItemRenderer.prepare() function and doing some stuff.
override public function prepare(hasBeenRecycled:Boolean):void
{
cb.selected = grid.selectionContainsIndex(rowIndex);//cb is CheckBox itemrenderer
}
when this prepare function called? and how many times? and what it does?
while debugging I noticed that this method was continuously called,
Is there any performance issues by overriding this method?
In flex, item renderers are constructed, destroyed and recycled automatically by the framework. It tries to recycle previously unused object to save resources.
The prepare is called when the item renderer is affected to a new row, cell, object, …
You can use it to initialize some labels, fields, …
If in debug you noticed is “continuously called” it is probably because of the following workflow:
– the item gain focus, framework calls prepare()
– your IDE stops in the method, then your application lost focus
– once you finished to debug, your application re gained focus, then the prepare method is called,
– etc, …
In definitive, either you use bindings to {data.myFields} to display the values automatically when the data object is affected (silently through the prepare method), otherwise you override this method to prepare some attributes for display.
In term of performance, everything should be similar.
HIH