+展开-XML
<mx:List xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private var _rendererStyle:String;
//here's the most effective way to ensure that we draw
//the item renderers only when we need them
override protected function makeRowsAndColumns(left:Number, top:Number,right:Number, bottom:Number, firstCol:int,firstRow:int, byCount:Boolean=false,rowsNeeded:uint=0.0):Point{
var pt:Point;
pt = super.makeRowsAndColumns(left, top, right,bottom, firstCol,firstRow, byCount, rowsNeeded);
if(_rendererStyle != null) {
rendererStyle = _rendererStyle;
}
return pt;
}
public function set rendererStyle(styleName:String):void {
_rendererStyle = styleName;
if( collection != null) {
var i:int = 0;
do {
try {
var comp:UIComponent =(indexToItemRenderer(i) as UIComponent);
if(comp.styleName == _rendererStyle){
comp.styleName = _rendererStyle;
comp.invalidateDisplayList();
} else { continue ; }
} catch (err:Error){}
i++;
}
while( i < rowCount )
}
}
public function get rendererStyle():String { return _rendererStyle; }
]]>
</mx:Script>
</mx:List>