flex3.0 的皮肤

1.写一个皮肤类,重新绘制背景

package com.component.checkboxdatagrid
{
 import com.hr.organization.view.Matrix;
 
 import flash.display.BitmapData;
 import flash.display.Graphics;
 import flash.display.Loader;
 import flash.display.Sprite;
 import flash.events.MouseEvent;
 import flash.geom.Matrix;
 import flash.geom.Rectangle;
 import flash.net.URLRequest;
 
 import mx.controls.Alert;
 import mx.graphics.BitmapFill;
 import mx.skins.ProgrammaticSkin;
 import mx.states.SetStyle;
 
 import org.alivepdf.fonts.Style;
 
 public class Ucskin extends ProgrammaticSkin
 {
  [Bindable]
  [Embed(source="com/hr/assets/common/11.png")]//绑定图片
  private static var Left_Up_Corner:Class;
  public function Ucskin()
  {
   super();
  }
  override public function get measuredWidth():Number {
   return 0;
  } 
  override public function get measuredHeight():Number {
   return 10;
  } 
  override protected  function updateDisplayList(w:Number, h:Number):void {//
   var borderColor:uint = getStyle("borderColor");
   var g:Graphics = graphics;
   var luc:BitmapData = new Left_Up_Corner().bitmapData;
   g.beginBitmapFill(luc,null,false,false);
   g.moveTo(0,0);
   g.lineStyle(1,borderColor);
   g.lineTo(0,h);
   
   g.drawRect(1,1,16,16);
   
   g.endFill();
   
   g.moveTo(16,h);
   g.lineStyle(1,borderColor);
   g.lineTo(0,h);
   this.addEventListener(MouseEvent.CLICK,cl);//添加方法,但是知道flex3.0皮肤是不支持用户互动的。。。所以没用。
   
   
   /*var g:Graphics = graphics;
   //g.beginBitmapFill(myBitmap);
   g.moveTo(0,0);
   g.lineStyle(1,borderColor);
   g.lineTo(0,h);*/
  }
  private function cl(evt:MouseEvent):void{
   Alert.show("sssssssssss");
  }
 }
 
}

2.使用

<mx:DataGrid

headerSeparatorSkin=“com.component.checkboxdatagrid.Ucskin ”

/>

完成了

 

你可能感兴趣的:(Flex)