2011-08-12 86 views
7

我试图在HBox上设置手形光标。我试过buttonMode和useHandCursor,但没有运气。此示例显示忙碌光标。任何人都可以告诉我如何让它显示flashPlayer的手形光标吗?Flex:如何设置手形光标?

<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> 

回答

6

这段代码显示它完美而鼠标在容器:

<?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> 
+0

^不为我工作。我得到箭头指针 - Squiff – Squiff

+0

您使用什么Flex SDK版本,Flash Player版本,操作系统和浏览器? – Constantiner

+0

Flash builder 4,MAC 10,3,181,14,OSX 10.6.7,Firefox 5.0.1 – Squiff

0

有大约一半通过本次论坛的讨论,你会发现有用的例子:

Custom CursorManager看帖子#7

+0

不幸的是,链接是关闭 –

+1

@ 1.21 gigawatts哎呀,一个链接只回答。我没有时间回顾问题和内容(并且我在一段时间内没有在flex中工作),但是如果您仍然需要它,这里有一个工作缓存的论坛副本! https://web.archive.org/web/20090110041612/http://www.actionscript.org/forums/showthread.php3?t=125314 –

2

如果你想在标签中设置手形光标,你必须设置mouseChildren =“false”,下面是修改后的代码

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

希望这对你有用。

0

您也可以使用较新的Mouse类,它提供了更高的帧频本机游标。

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

背景颜色和背景alpha用于绘制用作命中区域的图形。在空的Spark容器中有一个mouseEnabledWhereTransparent属性,我认为它不存在于mx容器中。这里是它的文档:

如果为true,此属性可确保组 的整个边界响应鼠标事件,如点击和翻转。如果将鼠标,触摸或Flash Player手势事件 添加到此实例,则此属性 只会生效。另外,它假设对 addEventListener()/ removeEventListener()的调用不是多余的。

话虽如此看来,这个工作没有设置mouseEnabledWhereTransparent属性:

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