Flex:如何设置手型光标?

7

我试图在一个HBox上设置手型光标。我尝试了buttonMode和useHandCursor,但没有成功。这个示例显示了忙碌光标。请问有人可以告诉我如何使它显示flashPlayer的手型光标吗?

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

4个回答

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>

你使用的是哪个Flex SDK版本、Flash Player版本、操作系统和浏览器? - Constantiner
Flash Builder 4,MAC 10.3.181.14,OSX 10.6.7,Firefox 5.0.1。 - Squiff
问题出在Firefox 5.0.1上。更新到Firefox 6版本,问题应该会得到解决。在Flash中,Firefox 4和5无法正确显示手形光标。 - Justin N

3

如果您想在标签中设置手形光标,必须设置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"/>

背景颜色和背景透明度用于绘制作为命中区域使用的图形。在空的 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"/>

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接