package skins { import flash.display.GradientType; import flash.geom.Matrix; import mx.skins.Border; import mx.utils.ColorUtil; public class AccordionButton extends Border { private var colBackground: uint = 0xFFFFFF; private var colBorder: uint = 0; private var borderThickness: uint = 1; private var borderAlpha: Number = 1; private var backgroundAlpha: Number = 1; private var colArrow: uint = 0xFFFFFF; private var colAlt: uint = 0xFFFFFF; private var isUp: Boolean = false; override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { graphics.clear(); colBorder= getStyle('borderColor'); colArrow = ColorUtil.adjustBrightness(colBorder, -50); colBackground = getStyle('fillColors')[0]; switch (name) { case "skin": break; case "overSkin": colBackground = getStyle('downFillColors')[0]; case "downSkin": colArrow = ColorUtil.adjustBrightness(colArrow, 150); break; } if (name.indexOf('elected') > 0) { isUp = true; } colAlt = ColorUtil.adjustBrightness(colBackground, 40); var matrix: Matrix = new Matrix(); matrix.createGradientBox(unscaledWidth, unscaledHeight, Math.PI/2, 0, 0); with (graphics) { lineStyle(borderThickness, colBorder, borderAlpha); beginGradientFill( GradientType.LINEAR, [colBackground, colAlt], [1, 1], [0, 170], matrix ); moveTo(1, unscaledHeight-1); curveTo(0, 0, unscaledHeight-3, 1); lineTo(unscaledWidth-3, 1); lineTo(unscaledWidth - 2, unscaledHeight - 1); lineTo(1, unscaledHeight-1); endFill(); } var cX: Number = unscaledWidth - 15; var cY: Number = unscaledHeight / 2; with (graphics) { if (isUp) { lineStyle(0, 0, 0); beginFill(colArrow); moveTo(cX - 5, cY + 5); lineTo(cX, cY - 5); lineTo(cX + 5, cY + 5); endFill(); } else { lineStyle(0, 0, 0); beginFill(colArrow); moveTo(cX - 5, cY - 5); lineTo(cX, cY + 5); lineTo(cX + 5, cY - 5); endFill(); } } } } }