package skins { import flash.display.GradientType; import flash.geom.Matrix; import mx.skins.ProgrammaticSkin; import mx.utils.ColorUtil; public class TitleWindowCloseButton extends ProgrammaticSkin { private var lineAlpha: Number = 0.4; private var lineColor: uint = 0xFFFFFF; private var lineThickness: int = 2; private var backgroundColor: uint = 0xFFFFFF; private var backgroundColorAlt: uint = 0xFFFFFF; private var borderColor: uint = 0; private var borderThickness: uint = 1; private var borderAlpha: Number = 1; private var backgroundAlpha: Number = 1; override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { graphics.clear(); unscaledWidth = unscaledHeight = 18; var action: String = (name.toLowerCase().indexOf('minimize') == -1) ? 'close' : 'min'; borderColor = getStyle(action + 'Border'); backgroundColor = getStyle(action + 'Colors')[1]; var showLines: Boolean = true; if (getStyle(action + 'Colors').length) { if (name.toLowerCase().indexOf('over') != -1) { backgroundColor = ColorUtil.adjustBrightness(getStyle(action + 'Colors')[1], 60); } else if (name.toLowerCase().indexOf('down') != -1) { backgroundColor = getStyle(action + 'ColorsPress')[1]; } else { showLines = false; backgroundColor = getStyle(action + 'Colors')[1]; } } backgroundColorAlt = ColorUtil.adjustBrightness(backgroundColor, 50); graphics.lineStyle(0, 0, 0); var rad: Number; var skinColor: uint = ColorUtil.adjustBrightness(backgroundColorAlt, 50);//0xCCCCCC; lineColor = 0; if (name.toLowerCase().indexOf('down') != -1) { lineColor = 0xFFFFFF; skinColor = ColorUtil.adjustBrightness(skinColor, -30); backgroundColorAlt = ColorUtil.adjustBrightness(backgroundColorAlt, - 30); } rad = unscaledHeight-2; var cols: Array = [ColorUtil.adjustBrightness(backgroundColorAlt, -60), backgroundColorAlt, skinColor, backgroundColorAlt, skinColor]; var alphas: Array = [1, 1, 1, 1, 1]; var ratios: Array = [65, 140, 180, 230, 255]; var matrix: Matrix = new Matrix(); matrix.createGradientBox(rad, rad, 0, - rad*0.05, 1); drawRoundRect(1, 1, rad, rad, rad, cols, alphas, matrix, GradientType.RADIAL, ratios); if (showLines) { var cX: int = rad/2; var cY: int = unscaledHeight/2; rad = 2; with (graphics) { lineStyle(lineThickness, lineColor, lineAlpha); if ('min' == action) { moveTo(cX - rad, cY); lineTo(cX + rad, cY); } else { moveTo(cX - rad, cY - rad); lineTo(cX + rad, cY + rad); moveTo(cX + rad, cY - rad); lineTo(cX - rad, cY + rad); } } } } } }