I'm using Flash Builder 4 and am in the process of learning.
The short and simple explanation is, I want a tab navigator that has tabs that look like this:
I know I could do this using an image-based skin, but I figured (and could be wrong) that programmatically drawing the shape would be better in terms of scalability.
As long as I get the result I'm looking for, I guess I don't really care if it's mx or spark. I tried doing this:
Main App:
<mx:ButtonBar dataProvider="{vsTabNav}" firstButtonStyle="firstButtonStyle"/>
CSS File:
.firstButtonStyle { skinClass:ClassReference("assets.skins.ButtonBarFirstButtonSkin"); }
ButtonBarFirstButtonSkin.as:
package assets.skins
{
import flash.display.Graphics;
import mx.skins.halo.ButtonBarButtonSkin;
import mx.graphics.RectangularDropShadow;
public class ButtonBarFirstButtonSkin extends ButtonBarButtonSkin
{
private var dropShadow:RectangularDropShadow;
public function ButtonBarFirstButtonSkin()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var cornerRadius:Number = getStyle("cornerRadius");
var backgroundColor:int = getStyle("backgroundColor");
var backgroundAlpha:Number = getStyle("backgroundAlpha");
graphics.clear();
cornerRadius = 10;
backgroundColor = 0xFF0000;
backgroundAlpha = 1;
// Background
drawRoundRect(0, 0, unscaledWidth, unscaledHeight, {tl:1, tr:cornerRadius, bl:1, br:1}, backgroundColor, backgroundAlpha);
// Shadow
if (!dropShadow)
dropShadow = new RectangularDropShadow();
dropShadow.distance = 8;
dropShadow.angle = 45;
dropShadow.color = 0;
dropShadow.alpha = 0.4;
dropShadow.tlRadius = 1;
dropShadow.trRadius = cornerRadius;
dropShadow.blRadius = 1;
dropShadow.brRadius = 1;
dropShadow.drawShadow(graphics, 0, 0, unscaledWidth, unscaledHeight);
}
}
}
This should mean that the first button will be red and will have a very round top-right corner. Instead, I just get the default button. Not sure what I'm doing wrong there, but if that's not the best solution, I would love some help. Thanks!