如何使用“本机” 在 Flash 应用程序中自定义鼠标光标?
在 Flash 应用程序中更改光标的最常见方法似乎是简单地隐藏本机操作系统光标并在 Flash 内显示图形(由 Flash Player 绘制) (隐藏)光标所在的矩形。 这就是 mx.managers.CursorManager
就是如此。 我发现这种方法不可接受的原因是 Flash Player 更新光标图形的速度不够快,导致光标移动出现一些非常明显的滞后,我发现这是一个非常基本的问题可用性问题和烦恼,使整个应用程序看起来比实际速度慢。
另一方面,我注意到 CSS 浏览器中的cursor
属性实现按其应有的方式工作——即,使用它来实现自定义鼠标光标时,光标移动没有明显的滞后。
所以我的问题是:是否有任何方法可以使用 CSS cursor
属性(或任何其他不涉及滞后、缓慢光标移动的方法)来更改 Flash 顶部的光标矩形?
我已经尝试通过 JavaScript 更改 Flash 元素(或 Flash 元素周围的 Div
包装器)的 cursor
样式属性,但没有似乎无法让它发挥作用。 有没有人成功地做过这样的事情?
The most common way of changing a cursor in Flash apps seems to be based on simply hiding the native OS cursor and displaying a graphic (drawn by the Flash Player) inside the Flash rectangle where the (hidden) cursor would be. This is what mx.managers.CursorManager
does, for example. The reason why I find this approach unacceptable is that Flash Player isn't nearly fast enough at updating the cursor graphic, leading to some very visible lag in the cursor movement, which I find to be a pretty fundamental usability problem and annoyance, making the whole app seem slower than it really is.
On the other hand, I've noticed that the CSS cursor
property implementation in browsers works like it should -- i.e. there's no visible lag in the cursor movement when using it to implement a custom mouse cursor.
So my question is: is there any way to use the CSS cursor
property (or any other method that doesn't involve lagging, slow cursor movement) to change the cursor on top of a Flash rectangle?
I've already tried to change the cursor
style property for a Flash element (or a Div
wrapper around the Flash element) via JavaScript, but didn't seem to get it to work. Has anyone successfully done something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Flash Player 10.2 beta 中提供了本机光标。 所以你应该尝试一下! 请参阅:http://www.bytearray.org/?p=2373
Native cursors are available in Flash Player 10.2 beta. So you should give it a try! See: http://www.bytearray.org/?p=2373
我不相信 Flash 有任何方法可以使用自定义系统光标。 在我作为 Flash 开发人员的 6 年里,我从未听说过这样的功能或 hack。
I don't believe there is any way for Flash to use custom system cursors. In my 6 years of being a Flash Developer I've never heard of such functionality or a hack.
我理解您的抱怨,我也对显示更新的滞后程度感到沮丧。 考虑使用 CSS 在浏览器中设置光标样式的解决方案虽然是一个有趣的方法...它闻起来很臭,但从顶部你可以使用ExternalInterface从 Actionscript 实现对 CSS 光标属性的控制。 这样您就可以与 HTML 容器进行通信,调用一些 Javascript 在运行时修改 HTML 页面 CSS。 不能 100% 确定这会起作用,但如果你绝望的话,可能值得一试。 否则,建议坚持使用 CursorManager。
I understand your complaints, I too have been frustrated with how laggy the display-update can be. Thinking about the solution to use CSS to set a cursor-style in the browser though is an interesting approach... It smells, but off the top you may be able to implement control over the CSS cursor attribute from Actionscript using ExternalInterface. That way you could presumably communicate back to the HTML container calling some Javascript to modify the HTML page CSS at runtime. Not 100% sure that will work, but it may be worth a try if you are desperate. Otherwise it's probably advisable to stick with CursorManager.
CursorManager 就是这样,但我没有遇到任何延迟问题。
如果您还没有看过它,请查看 Colin Moock 的 CustomMousePointer 类。 他在 http://www.Essential AS3 书中提供了大量 AS3 示例和示例代码。 moock.org/eas3/examples/。 向下滚动到或搜索“自定义鼠标指针”链接。 它位于第 22 章标题下。
顺便说一句,这些示例中的代码最初是供 Flash 开发人员使用的,因此您可以通过使用 Flash AS3 实现中不可用的对象来针对 Flex 优化其中一些代码。
The CursorManager is it, but I haven't had any problems with being laggy.
If you haven't already seen it, check out Colin Moock's CustomMousePointer classes. He has a bunch of AS3 examples and sample code from his Essential AS3 book posted at http://www.moock.org/eas3/examples/. Scroll down to, or search for, the Custom Mouse Pointer link. It's under the Chapter 22 heading.
The code in these examples, incidentally, was originally intended for use by Flash developers, so you may be able to optimize some of them for Flex by using objects that aren't available in Flash's implementation of AS3.
我相信 Flash Player 10 本身会让您选择 ibar、拖动手、手指或普通光标,但如果您使用的是 Flash 9,这是不可能的,而且我也不相信 CSS hack 会起作用。
我的建议是 - 使用 MOUSE_MOVE 事件来定位图形并将帧速率设置为尽可能高(例如每秒 50 帧)。
I believe Flash Player 10 will natively let you select the ibar, drag hand, finger or normal cursors, but if you're in Flash 9 this isn't possible and I don't believe a CSS hack will work either.
My advice is - use the MOUSE_MOVE event to position a graphic and set the frame rate as high as possible (e.g. 50 frames per second).
事实上,您可以通过编写一个调用 javascript 来更新鼠标光标的外部接口来实现此目的。 jQuery 功能在这里可以很好地工作,这是我在我的新投资组合网站中为按钮和 Flash 应用程序的各个区域所做的事情。
新的作品集尚未发布,但对于那些好奇的人来说,应该会在接下来的一两周内发布在 http://chrismcintoshdesigns 上。 com
You could in fact accomplish this by writing an ExternalInterface that calls javascript to update the Mousecursor. jQuery functionality would work well here and it is something im doing in my new portfolio site for buttons and various areas of the flash app.
The new portfolio is not up yet, but should be within the next week or two for those are curious it will be at http://chrismcintoshdesigns.com