Flex: How to set a manual cursor?

I am trying to set the cursor to HBox. I tried buttonMode and useHandCursor but no luck. This example displays the loaded cursor. Can someone tell me how to make it display the flashPlayer mouse cursor?

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="com.dn2k.components.*" > <fx:Script> <![CDATA[ private var cursorID:int; //cursorManager protected function box_mouseOverHandler(event:MouseEvent):void { cursorManager.setBusyCursor() } ]]> </fx:Script> <mx:HBox id="box" useHandCursor="true" buttonMode="true" mouseChildren="false" backgroundColor="0xcc0000" mouseOver="box_mouseOverHandler(event)"> <s:Label text="Hiya sexy..."/> </mx:HBox> 

+7
source share
5 answers

This code shows this perfectly when the mouse is above the container:

 <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"> <mx:HBox backgroundColor="0xcc0000" buttonMode="true" id="box" mouseChildren="false" useHandCursor="true"> <s:Label text="Hiya sexy..." /> </mx:HBox> </s:Application> 
+6
source

If you want to set the cursor in Label, you must set mouseChildren = "false", and below is the revised code

 <mx:HBox backgroundColor="0xcc0000" buttonMode="true" id="box" useHandCursor="true"> <s:Label text="Hiya sexy..." buttonMode="true" mouseChildren="false" useHandCursor="true" /> </mx:HBox> 

Hope this works for you.

+2
source

What did Jeff say. You can also use CursorManager.setCursor() . You will have to insert graphics for the cursor, though.

0
source

Here's an example about halfway through this forum discussion, which might be useful:

Custom CursorManager See Message # 7

0
source

You can also use the new Mouse class, which provides a native cursor with a higher frame rate.

 <mx:HBox rollOver="Mouse.cursor = MouseCursor.BUTTON" backgroundColor="0" backgroundAlpha="0" rollOut="Mouse.cursor = MouseCursor.AUTO"/> 

Background color and background alpha are used to highlight graphics that are used as the hit area. In empty Spark containers, there is a mouseEnabledWhereTransparent property, which I think does not exist in mx containers. Here is the documentation for it:

When true, this property ensures that all group boundaries are responsive to mouse events, such as clicking and rolling. This property only takes effect if mouse gesture, touch, or flash player events are added to this instance. In addition, it is suggested that calls to addEventListener () / removeEventListener () are not redundant.

Having said that, this works without setting the mouseEnabledWhereTransparent property:

 <s:Group id="testingHitGroup" left="10" top="10" rollOver="cursorObject_rollOver(event)" width="100" height="100"/> 
0
source

All Articles