package skins { import mx.skins.Border; import mx.utils.ColorUtil; public class TitleBorder extends Border { 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; private var borderOutThickness: Number = 2; override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { graphics.clear(); borderColor = getStyle('borderColor'); backgroundColor = getStyle('backgroundColor'); super.updateDisplayList(unscaledWidth, unscaledHeight); var headerHeight: Number = getStyle('headerHeight'); var cols: Array = [0xFFFFFF, borderColor, ColorUtil.adjustBrightness(borderColor, -20)]; graphics.lineStyle(0, 0, 0); drawRoundRect(0, 0, unscaledWidth, unscaledHeight, 0, backgroundColor, 1); if (headerHeight) { drawRoundRect(0, 0, unscaledWidth, headerHeight+1, 0, cols[2], 1); } var lw1: int, lw2: int, lw3: int; with (graphics) { if (unscaledHeight > headerHeight + 5) { //left border, ---> lw1 = 2; lineStyle(lw1, cols[0], 1); moveTo(lw1/2, headerHeight); lineTo(lw1/2, unscaledHeight-lw1/2); lw2 = 2; lineStyle(lw2, cols[1], 1); moveTo(lw1+lw2/2, headerHeight); lineTo(lw1+lw2/2, unscaledHeight-lw1 - lw2/2); lw3 = 1; lineStyle(lw3, cols[2], 1); moveTo(lw1+lw2+lw3/2, headerHeight); lineTo(lw1+lw2+lw3/2, unscaledHeight-lw1-lw2-lw3/2); //right <--- lw1 = 1; lineStyle(lw1, cols[2], 1); moveTo(unscaledWidth-lw1/2, headerHeight); lineTo(unscaledWidth-lw1/2, unscaledHeight-lw1/2); lw2 = 2; lineStyle(lw2, cols[1], 1); moveTo(unscaledWidth-(lw1+lw2/2), headerHeight); lineTo(unscaledWidth-(lw1+lw2/2), unscaledHeight-lw1 - lw2/2); lw3 = 2; lineStyle(lw3, cols[0], 1); moveTo(unscaledWidth-(lw1+lw2+lw3/2), headerHeight); lineTo(unscaledWidth-(lw1+lw2+lw3/2), unscaledHeight-lw1-lw2-lw3/2); //bottom up-down lw1 = 1; lineStyle(lw1, cols[2], 1); moveTo(lw1/2, unscaledHeight-lw1/2); lineTo(unscaledWidth-lw1/2, unscaledHeight-lw1/2); lw2 = 2; lineStyle(lw2, cols[1], 1); moveTo(lw1+lw2/2, unscaledHeight-(lw1+lw2/2)); lineTo(unscaledWidth-(lw1+lw2/2), unscaledHeight-(lw1 + lw2/2)); lw3 = 2; lineStyle(lw3, cols[0], 1); moveTo(lw1+lw2+lw3/2+1, unscaledHeight-(lw1+lw2+lw3/2)); lineTo(unscaledWidth-(lw1+lw2+lw3/2), unscaledHeight-(lw1+lw2+lw3/2)); } if (headerHeight) { lw1 = 2; lineStyle(lw1, cols[0], 1); moveTo(lw1/2, headerHeight) lineTo(lw1/2, lw1/2); lineTo(unscaledWidth-lw1/2, lw1/2); lineStyle(lw1, cols[2], 1); lineTo(unscaledWidth-lw1/2, headerHeight); //inner lw1 = 1; var padding: int = 5; lineStyle(lw1, cols[0], 1); moveTo(padding, headerHeight - 2); lineTo(padding, padding); lineTo(unscaledWidth - padding, padding); lineTo(unscaledWidth - padding, headerHeight - 2); lineStyle(lw1, ColorUtil.adjustBrightness(cols[2], 20), 1); moveTo(padding-1, headerHeight - 2); lineTo(padding-1, padding-1); lineTo(unscaledWidth - padding + 1, padding-1); lineTo(unscaledWidth - padding + 1, headerHeight - 2); //lefttop cut lw1 = 1; lineStyle(lw1, ColorUtil.adjustBrightness(cols[2], 20), 1); moveTo(headerHeight-1, 1); lineTo(headerHeight-1, headerHeight -2); lineStyle(lw1, cols[0], 1); moveTo(headerHeight, 1); lineTo(headerHeight, headerHeight -2); //righttop lineStyle(lw1, ColorUtil.adjustBrightness(cols[2], 20), 1); moveTo(unscaledWidth - headerHeight-2, 1); lineTo(unscaledWidth - headerHeight-2, headerHeight -2); lineStyle(lw1, cols[0], 1); moveTo(unscaledWidth - headerHeight-1, 1); lineTo(unscaledWidth - headerHeight-1, headerHeight -2); } //cuts if (unscaledHeight > headerHeight) { var size: int = 2; //bottom lineStyle(1, ColorUtil.adjustBrightness(cols[0], -20), 1); drawRect(1, unscaledHeight-headerHeight, size, 1); drawRect(unscaledWidth - 1 - size, unscaledHeight-headerHeight, size, 1); drawRect(headerHeight, unscaledHeight-1-size, 1, size); drawRect(unscaledWidth-headerHeight, unscaledHeight-1-size, 1, size); } } } } }