开发者

How to trap mouse cursor in Flex/Flash?

I'm working on an interface control that allows users to navigate a 3d space with their mouse. Currently we are using up/down/left/right arrow buttons, but what I'd really like to switch to is a clickwheel type interface.

The interaction I'm looking for is:

  1. User clicks "Up" section of click wheel.
  2. Mouse cursor disappears.
  3. User drags mouse up to quickly move forward through location
  4. User drags mouse down to qui开发者_如何转开发ckly move backward through location
  5. User releases mouse button and cursor reappears, still inside click wheel

The problem I see with this is that the invisible mouse will quickly move out of the movie and stop tracking. Has anybody dealt with this before? I'm sure I saw a flash toy somewhere that trapped the mouse inside a box, but can't find it now. :(


It's impossible to 'trap' the mouse cursor. The best you can do is hide the cursor (or not) and just increase the ratio between mouse movement and whatever you're trying to do.


Like others have said, you can't trap the mouse (the web would be an awful place if arbitrary web code could do this), but you can detect when the mouse has exited the swf and perform logic to handle this occurance by listening for Event.MOUSE_LEAVE. Perhaps you can interpret this event as though it were a mouse_up event?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜