创建Skin可以继承自各个skin(见帮助)
如:继承ButtonSkin
重写(override) updateDisplayList方法
name变量为upSkin、overSkin、downSkin等。
private var backgroundFillColor:Number;
override protected function updateDisplayList(unscaleWidth:Number,unscaledHeight:Number):void{
super.updateDisplayList(unscaleWidth,unscaledHeight);
switch(name){
case "upSkin":
backgroundFillColor = 0x666666;
break;
case "overSkin":
backgroundFillColor = 0xcccccc;
break;
case "downSkin":
backgroundFillColor = 0xffffff;
break;
}
graphics.clear();
graphics.beginFill(backgroundFillColor);
graphics.drawRoundRectComplex(0,0,unscaleWidth,unscaleHeigt,0,20,20,0);
graphics.endFill();
}
在css中引用,将overSkin upSkin downSkin指向skin类:
Button{
overSkin: ClassRefrence("skins.myButtonSkin")(类名)
upSkin: ClassRefrence("skins.myButtonSkin")
downSkin: ClassRefrence("skins.myButtonSkin")
}
skin
猜你喜欢
转载自blog.csdn.net/kingapex1/article/details/83454464
今日推荐
周排行