flex3可编程皮肤
flex3可编程皮肤
效果图:
package com{import mx.skins.ProgrammaticSkin;public class MySkin extends ProgrammaticSkin{public function MySkin(){super();}overrideprotected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{var line:Number=4;var backgroundColoe:Number;switch(name){case "upSkin":backgroundColoe=0xEA800C;break;case "overSkin":backgroundColoe=0xF8B872;break;case "downSkin":backgroundColoe=0xB06109;break;case "disabledSkin":backgroundColoe=0xB06109;break;}graphics.clear();graphics.beginFill(backgroundColoe);graphics.drawEllipse(0,0,unscaledWidth,unscaledHeight);graphics.endFill();}}}
package{import flash.display.Bitmap; import flash.display.BitmapData; import mx.skins.RectangularBorder; public class MetalBackground extends RectangularBorder { [Embed(source='file.png')] private var backgroundImageClass:Class; private var backgroundBitmapData:BitmapData; public function MetalBackground() { super(); var backgroundImage:Bitmap = new backgroundImageClass(); backgroundBitmapData = new BitmapData(backgroundImage.width,backgroundImage.height); backgroundBitmapData.draw(backgroundImage); } override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number ):void { super.updateDisplayList(unscaledWidth,unscaledHeight ); var cornerRadius:Number = getStyle("cornerRadius"); graphics.clear(); graphics.beginBitmapFill( backgroundBitmapData ); graphics.drawRoundRectComplex(0,0,unscaledWidth,unscaledHeight,cornerRadius,cornerRadius,cornerRadius,cornerRadius ); graphics.endFill(); } } }