flex中修改skin 转帖
flex中修改skin
创建Skin可以继承自各个skin(见帮助) 如:继承LinkButtonSkin 重写(override) updateDisplayList方法 name变量为upSkin、overSkin、downSkin等。
public class MenuButtonSkin extends LinkButtonSkin { private var backgroundFillColor:Number; private var cornerRadius:int = 4; public function MenuButtonSkin() { super(); }
override protected function updateDisplayList(w:Number, h:Number) : void{
super.updateDisplayList(w, h);
graphics.clear();
trace("name:"+name);
switch(name){
case "upSkin":
backgroundFillColor = 0xF0F0F0;
break;
case "overSkin":
backgroundFillColor = 0x666666;
break;
case "downSkin":
backgroundFillColor = 0x000000;
break;
case "disabledSkin":
backgroundFillColor = 0xff0000;
break;
}
drawRoundRect(0,0,w,h,cornerRadius,backgroundFillColor,1);
}
} 在css中引用,将overSkin upSkin downSkin指向skin类:
mx|LinkButton{ skin: ClassRefrence("skins.MenuButtonSkin") //类名 }