2011-08-12 80 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"/>