Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flash/Flex Cursors

I work on a Flex app that loads external Flash resources created in CS3. I've just been reading about how I can use the Flex mx.managers.CursorManager class to change the mouse cursor explicitly. But what I'd ideally like to do is to set a mouse cursor property on some elements in the loaded Flash SWF, so as the cursor passes over this element the cursor automatically changes without me having to respond to mouse events.

Is it possible? Does Flash support this in DisplayObject or something?

It seems the Flash SWF is overriding me. Some objects automatically display the hand cursor with mouse-over, and I can't see a way to turn this off on a DisplayObject?

like image 520
MidnightGun Avatar asked Jan 09 '09 11:01

MidnightGun


2 Answers

To set the the "Hand" cursor, as soon as the mouse hovers over a element you have to specify these properties:

  <mx:VBox 
       useHandCursor="true"
       mouseChildren="false"
       buttonMode="true">

However this only works for the Hand cursor. Also take care of the required mouseChildren attribute. You either have to set this to false to achieve the cursor for all contained items or you have to specify the attributes useHandCursor and buttonMode for all elements. However the side effect of settings mouseChildren to false is that all mouse events (mouseOver, mouseOut, click,...) on child elements will no longer work.

In case you want to use a different cursor than the hand cursor I am afraid you have only two possibilities:

  • Replace the standard hand cursor by your cursor
  • Use the mouseOver and mouseOut events to set the cursor programmatically.
like image 95
Yaba Avatar answered Sep 30 '22 06:09

Yaba


In any object inheriting from Sprite whose buttonMode and useHandCursor properties are both true, you'll get a hand cursor by default when you roll over it. Some objects do this by default, correct; Button and LinkButton are examples you've probably noticed. Simply setting useHandCursor to false on any of these components will disable the hand cursor easily enough, even when its buttonMode property (which is responsible for dispatching click events) is set to true.

If you want to set your cursor to anything else on mouseOver, though, you'll have to respond to mouse events; there's no way around that. Depending on your design goal, you could break that work out somehow, maybe by inheriting from some other object and then overriding its default behavior, but in some form or other, the runtime needs to know you want those mouse events handled.

like image 35
Christian Nunciato Avatar answered Sep 30 '22 07:09

Christian Nunciato