Flex HDividedBox Divider backgroundColor
Is there an easy way to set the backgroundColor of a HDividedBox's (or VDividedBo开发者_如何学运维x's) BoxDivider object(s)? A BoxDivider is the "divider" that has the drag handle on it.
By default, the BoxDivider is transparent with the little handle image on it.
There is a dividerSkin style that defaults to mx.skin.BoxDividerSkin which is a reference to a symbol in the Assets.swf file.
Any ideas? Do I have to make an alternate skin? Is that my only option? Googling this led me to many solutions that were weird and hacky and frankly didn't seem to work.
Thanks.
OK, here's how you do this:
- create a class that extends ProgrammaticSkin
- override updatedisplaylist method like this:
override protected function updateDisplayList(w:Number, h:Number):void
{
var divwidth:Number = getStyle("dividerThickness");
if (divwidth == 0)
{
divwidth = 10;
}
graphics.clear();
graphics.beginFill(0xFF0000, 1.0);
graphics.drawRect(-(parent.height / 2), -(divwidth / 2), parent.height, divwidth);
graphics.endFill();
}
then add this to your hdivided box
<mx:HDividedBox dividerSkin="path.MyDividerSkin"/>
by default, the skin gets added to the middle of the divider so you need to offset the x & y...
Also, you could extend DividedBox and override the updateDisplayList to something like this:
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w,h);
graphics.clear();
var n:int = numDividers;
graphics.beginFill(0xFF0000, 1.0);
for (var i:int = 0; i < n; i++)
{
var box:BoxDivider = getDividerAt(i);
graphics.drawRect(box.x, box.y, box.width, box.height);
}
graphics.endFill();
}
I'd love to be able to create a simple programmatic skin for each dividedbox. so i can just do this:
<mx:HDividedBox dividerSkin="path.MyDividerSkin"
but I'm having difficulty figuring out what the MyDividerSkin class should look like. You think this would be easy. :)
精彩评论