The following example shows how you can set a horizontal divider cursor on a Flex HDividedBox container by setting the horizontalDividerCursor style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/09/setting-the-horizontal-divider-cursor-on-an-hdividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_horizontalDividerCursor_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:HDividedBox id="hDividedBox"
horizontalDividerCursor="@Embed('assets/arrow_refresh.png')"
width="100%"
height="100%">
<mx:HBox backgroundColor="haloGreen"
width="100%"
height="100%">
</mx:HBox>
<mx:HBox backgroundColor="haloBlue"
width="100%"
height="100%">
</mx:HBox>
</mx:HDividedBox>
</mx:Application>
View source is enabled in the following example.
You can also set the horizontalDividerCursor style using 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/10/09/setting-the-horizontal-divider-cursor-on-an-hdividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_horizontalDividerCursor_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
HDividedBox {
horizontalDividerCursor: Embed("assets/arrow_refresh.png");
}
</mx:Style>
<mx:HDividedBox id="hDividedBox"
width="100%"
height="100%">
<mx:HBox backgroundColor="haloGreen"
width="100%"
height="100%">
</mx:HBox>
<mx:HBox backgroundColor="haloBlue"
width="100%"
height="100%">
</mx:HBox>
</mx:HDividedBox>
</mx:Application>
Or, you can set the horizontalDividerCursor style using ActionScript, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/09/setting-the-horizontal-divider-cursor-on-an-hdividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_horizontalDividerCursor_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
[Embed("assets/arrow_refresh.png")]
private const ArrowRefreshIcon:Class;
private function hDividedBox_init():void {
hDividedBox.setStyle("horizontalDividerCursor", ArrowRefreshIcon);
}
]]>
</mx:Script>
<mx:HDividedBox id="hDividedBox"
width="100%"
height="100%"
initialize="hDividedBox_init();">
<mx:HBox backgroundColor="haloGreen"
width="100%"
height="100%">
</mx:HBox>
<mx:HBox backgroundColor="haloBlue"
width="100%"
height="100%">
</mx:HBox>
</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/10/09/setting-the-horizontal-divider-cursor-on-an-hdividedbox-container-in-flex/ -->
<mx:Application name="HDividedBox_horizontalDividerCursor_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.containers.HBox;
import mx.containers.HDividedBox;
[Embed("assets/arrow_refresh.png")]
private const ArrowRefreshIcon:Class;
private var hDividedBox:HDividedBox;
private var hBox1:HBox;
private var hBox2:HBox;
private function init():void {
hBox1 = new HBox();
hBox1.percentWidth = 100;
hBox1.percentHeight = 100;
hBox1.setStyle("backgroundColor", "haloGreen");
hBox2 = new HBox();
hBox2.percentWidth = 100;
hBox2.percentHeight = 100;
hBox2.setStyle("backgroundColor", "haloBlue");
hDividedBox = new HDividedBox();
hDividedBox.percentWidth = 100;
hDividedBox.percentHeight = 100;
hDividedBox.addChild(hBox1);
hDividedBox.addChild(hBox2);
hDividedBox.setStyle("horizontalDividerCursor",
ArrowRefreshIcon);
addChild(hDividedBox);
}
]]>
</mx:Script>
</mx:Application>



Help! Peter pls help me. I’m a little new to flex and it is kicking the syit out of me =[
I have a flex app that contains height 100% values for all containers. Thats how i want it, like flashs ability to resize dynamically through the stage methods, hmm can i implement these straightforwardly in flex, is that necessary?
The problem is when i open a new browser tab window (i test in firefox), having 2 tabs open. I find that when i switch from the second new tab to the first tab, my menu, which is positioned at the bottom of the screen, and application, does not resize in the original tab which has dropped down to display the new tab. In other words the application does not shrink to fit its new dimensions in the first tab. I don’t like this behaviour. I’ve searched google but i keep coming up short and i’ve spent the whole night working on embedding fonts and fades and i’m so tired and under pressure my brain is like peanut butter right now. Everything worked ok before but i made some changes and cannot retain the original. I’ve looked at the livedocs but they seem to be written by men with grey hair who are mental.
Can you help me pls. I apologise for using this unrelated page in which to communicate Peter but i thought as it is a new one chances are you may be monitoring it more closely. Peter i have found 90% of my flex answers from this site. The advertisers are at least getting value for money =]. Saul
Hmm, i just went to Flex style explorer and it replicates the same behaviour as i described above. WTF is going on!
Fixed It! I should really keep my learning process private but tiredness kills!
Invaluable blog BTW.
Just so you know:
The problem i described here seems to be a bug with Firefox 3.0.3.
Solution is to add margin-top:1px;
html, body { margin:0px; margin-top:1px; padding:0px; overflow:hidden; height:100%; }found @
http://www.ultrashock.com/forums/flash-professional/onresize-and-new-tab-in-firefox-89217.html
And, Yes It Works!
I actually have the exact same problem, I thought I could place a setInterval with a sizecheck to auto-resize if the old height is different from actual height. But it seems when I add a second tab it doesn’t work.
Hi That I want change the default Cursor style in the canvas ,And I need your help
:) Thank you~~!
Yangyan,
Check out “Changing the cursor in a Flex application using the CursorManager class”.
Peter