FLASH组件 DataGrid中文及字体样式设置(写as3类)

来源:互联网 发布:电脑大型网络3d游戏 编辑:程序博客网 时间:2024/05/16 06:06
在FLASH组件当中,单独为DataGrid设置字体样式较为特殊,总结了一下,还是单独写类的方法更灵活些。
首先,编写样式类:


package style{
import fl.controls.listClasses.CellRenderer;
import fl.controls.listClasses.ICellRenderer;
import flash.text.TextFormat;
public class CellStyle1 extends CellRenderer implements ICellRenderer {


   public function CellStyle1():void {
    super();
   }


   override protected function drawBackground():void {
    var format:TextFormat = new TextFormat();


    format.color=0x000000;
    format.size=12;
    format.font="宋体";
    setStyle("textFormat",format);
    super.drawBackground();
   }
}
}


然后引用类:
import style.CellStyle1;
给具体的实例设置样式(本例为:_DataGrid)
this._DataGrid.setStyle("cellRenderer",CellStyle1);