这可能是沿着路径锁定鼠标,如果是这样的话怎么样?

时间:2013-08-25 13:10:45

标签: actionscript-3 flash-cs6

我希望能够锁定鼠标才能沿弧线移动。这可能吗?如果是这样怎么样?我试过在谷歌和论坛上寻找。我发现的只是将动画片段锁定到一个路径。我在Adobe Flash CS6中使用ActionScript 3。

2 个答案:

答案 0 :(得分:0)

  • 隐藏鼠标光标
  • 创建自定义光标(如实际光标)
  • 更改光标位置(使用鼠标位置)

这段代码会给你一个想法

Mouse.hide();
var path:Array=[new Point(0,0),new Point(50,20),new Point(150,40),new Point(250,60),new Point(300,70),new Point(400,80)];
var myCursor:Sprite=new Sprite();
myCursor.graphics.beginFill(0);
myCursor.graphics.drawCircle(0,0,5);
myCursor.graphics.endFill();
addChild(myCursor);

stage.addEventListener(MouseEvent.MOUSE_MOVE,refreshCursorPosition);
function refreshCursorPosition(e:MouseEvent):void{
    if(e.stageX<0 || e.stageX>stage.stageWidth)
        return;
    var pos:int=Math.floor(e.stageX*path.length/stage.stageWidth);
    myCursor.x=path[pos].x;
    myCursor.y=path[pos].y;
}

答案 1 :(得分:0)

此文档可能正是您所需要的。 http://evolve.reintroducing.com/2011/05/09/as3/as3-drag-a-clip-along-an-arc/

首先看一下这个例子。

相关问题