在纯 AS3 / Flare 项目中替换光标的方法?

发布于 2024-08-30 05:50:24 字数 427 浏览 3 评论 0原文

我有一个纯 AS3(无 Flex)项目,它使用 Flare 来显示数据可视化并与数据可视化交互。我刚刚实现了一些平移行为,因此您可以单击并拖动可视化效果,现在我想通过使用漂亮的手形图标切换箭头光标,为用户提供一个视觉指示符,表明这是可能的。

用户可以随时单击并拖动,除非鼠标位于可单击节点上(此时光标交换为指针 - 此行为已就位)。

所以...
1) 我是否需要创建自己的自定义位图/精灵,或者是否有可以使用的内置光标调色板? (我没有使用 Flex。)

2)有没有一种方法可以简单地用项目范围内的平移光标替换默认箭头,或者我是否需要将交换附加到显示对象上的鼠标事件?我可以使用舞台对象使此行为适用于所有地方吗?

3)如何进行交换?我是直接使用 Cursor 对象还是需要涉及 CursorManager?

任何指导、伪代码或智慧之言都将不胜感激!

I've got a pure AS3 (no Flex) project that uses Flare to display and interact with a data visualization. I just implemented some panning behavior, so you can click and drag the visualization around, and now I'd like to give the user a visual indicator that this is possible, by switching the arrow cursor with a nice grabby-looking hand icon.

The user can click and drag at any time except when the mouse is over a clickable node (at which time the cursor swaps to a pointer - this behavior is already in place).

So...
1) Do I need to create my own custom bitmap/sprite or is there a palette of built-in cursors I can use? (I'm not using Flex.)

2) Is there a way to simply replace the default arrow with the pan cursor project-wide, or do I need to attach the swapping to mouse events on display objects? Can I use the stage object to make this behavior apply everywhere?

3) How do I perform the swap? Do I use the Cursor object directly or do I need to get involved with the CursorManager?

Any guidance, pseudo-code, or words of wisdom is greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鼻尖触碰 2024-09-06 05:50:24

我不认为flash中有CursorManger,只有flex。我正在做的方式是使用一个自定义类,它隐藏光标并在 mouse_move 处拖动自定义光标。您必须将其设置为 mouseChildren=false,否则将出现 flickr 或按钮将无法单击。我发现的一个问题是自定义上下文菜单。试试这个链接 http://abrahamyan.com/2009/03/23/as3-光标管理器/

I don't think there's a CursorManger in flash, only flex. The way i'm doing is with a custom class which hides the cursor and drags the customized cursor at mouse_move. You have to set it to mouseChildren=false, otherwise will flickr or the buttons will not be clickable. One problem i found is with custom contextual menus. Try this link http://abrahamyan.com/2009/03/23/as3-cursormanager/

杀手六號 2024-09-06 05:50:24

我学到了一些东西(真的都是新手)。首先,您可以通过将 Mouse.cursor 设置为 MouseCursor.TYPE 的任何选项来设置一些内置光标选项。 Mouse 对象是应用程序范围内可用的单例,因此无论您在代码中更改它,该更改都会持续存在,直到触发另一个更改为止。
对于我的简单情况,我这样做了:

    //on init, start with the "hand"
    Mouse.cursor = MouseCursor.HAND;

    //on clickable items, change to "pointer", then back to "hand"
    myClickableNode.addEventListener(MouseEvent.ROLL_OVER, function(evt:Event):void {
      Mouse.cursor = MouseCursor.BUTTON;
    });
    myClickableNode.addEventListener(MouseEvent.ROLL_OUT, function(evt:Event):void {
    Mouse.cursor = MouseCursor.HAND;
    });

结果是你总是拥有“手”,直到你滚动可点击的东西,然后你得到“指针”。

A few things I learned (all pretty newby, really). Firstly, there are some built-in cursor options you can set by setting Mouse.cursor to any of the options of MouseCursor.TYPE. The Mouse object is a singleton available app-wide, so anywhere you change it in your code, the change persists until another change is triggered.
For my simple case, I did this:

    //on init, start with the "hand"
    Mouse.cursor = MouseCursor.HAND;

    //on clickable items, change to "pointer", then back to "hand"
    myClickableNode.addEventListener(MouseEvent.ROLL_OVER, function(evt:Event):void {
      Mouse.cursor = MouseCursor.BUTTON;
    });
    myClickableNode.addEventListener(MouseEvent.ROLL_OUT, function(evt:Event):void {
    Mouse.cursor = MouseCursor.HAND;
    });

The result is you always have the "hand" until you rollover something clickable, then you get the "pointer".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文