The following example shows how you can customize the divider skin on a Flex HDividedBox or VDividedBox container by setting the dividerSkin style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/18/customizing-the-divider-skin-on-a-dividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_dividerSkin_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:HDividedBox id="dividedBox"
dividerSkin="@Embed('assets/DividedBox.png')"
horizontalGap="24"
width="100%"
height="100%">
<mx:Box id="box1"
backgroundColor="haloGreen"
width="100%"
height="100%"
minWidth="100" />
<mx:Box id="box2"
backgroundColor="haloBlue"
width="100%"
height="100%"
minWidth="100" />
</mx:HDividedBox>
</mx:Application>
View source is enabled in the following example.
You can also set the dividerSkin style in an external .CSS file or <mx:Style /> block, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/18/customizing-the-divider-skin-on-a-dividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_dividerSkin_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
HDividedBox {
dividerSkin: Embed("assets/DividedBox.png");
horizontalGap: 24;
}
</mx:Style>
<mx:HDividedBox id="dividedBox"
width="100%"
height="100%">
<mx:Box id="box1"
backgroundColor="haloGreen"
width="100%"
height="100%"
minWidth="100" />
<mx:Box id="box2"
backgroundColor="haloBlue"
width="100%"
height="100%"
minWidth="100" />
</mx:HDividedBox>
</mx:Application>
Or, you can set the dividerSkin style using ActionScript, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/18/customizing-the-divider-skin-on-a-dividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_dividerSkin_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="init();">
<mx:Script>
<![CDATA[
[Embed("assets/DividedBox.png")]
private const customDividerSkin:Class;
private function init():void {
dividedBox.setStyle("dividerSkin", customDividerSkin);
}
]]>
</mx:Script>
<mx:HDividedBox id="dividedBox"
horizontalGap="24"
width="100%"
height="100%">
<mx:Box id="box1"
backgroundColor="haloGreen"
width="100%"
height="100%"
minWidth="100" />
<mx:Box id="box2"
backgroundColor="haloBlue"
width="100%"
height="100%"
minWidth="100" />
</mx:HDividedBox>
</mx:Application>
Due to popular demand, here is the “same” example in a more ActionScript friendly format:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/18/customizing-the-divider-skin-on-a-dividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_dividerSkin_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.containers.Box;
import mx.containers.HDividedBox;
[Embed("assets/DividedBox.png")]
private const customDividerSkin:Class;
private var dividedBox:HDividedBox;
private var box1:Box;
private var box2:Box;
private function init():void {
box1 = new Box();
box1.percentWidth = 100;
box1.percentHeight = 100;
box1.minWidth = 100;
box1.setStyle("backgroundColor", "haloGreen");
box2 = new Box();
box2.percentWidth = 100;
box2.percentHeight = 100;
box2.minWidth = 100;
box2.setStyle("backgroundColor", "haloBlue");
dividedBox = new HDividedBox();
dividedBox.percentWidth = 100;
dividedBox.percentHeight = 100;
dividedBox.setStyle("dividerSkin", customDividerSkin);
dividedBox.setStyle("horizontalGap", 24);
dividedBox.addChild(box1);
dividedBox.addChild(box2);
addChild(dividedBox);
}
]]>
</mx:Script>
</mx:Application>




Actually, coming from a html/css/javascript background - I think it’s great that you first and foremost show MXML examples :-) I love the simplicity.