2014-07-22 28 views
0

我正在通過startDrag()在AS3中添加自定義光標。在Mac上,它工作正常。你翻轉你的Flash文件,並且自定義的MC捕捉到鼠標。在電腦上,在載入時,光標立即跳轉到您的鼠標位於閃存文件外的任何位置。一個很好的例子來測試是這樣的:StartDrag()AS3惱人的快照

http://www.republicofcode.com/tutorials/flash/as3customcursor/

嘗試刷新在PC與MAC這個頁面,你會看到光標的初始位置是不同的。在PC上跳躍。我該如何解決?謝謝你,

+0

您可以延遲開始拖動,直到第一個mouseMove事件發生。只是好奇,有什麼大不了的? – BadFeelingAboutThis

+0

在捕捉光標前檢查鼠標是否位於屏幕視圖內。 – BotMaster

回答

0

你可以嘗試延遲進行拖動,直到鼠標移動事件是在舞臺的邊界之後。

stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler); 

function mouseMoveHandler(e:MouseEvent):void { 
    if(e.stageX > 0 && e.stageX < stage.stageWidth && e.stageY > 0 && e.stageY < stage.stageHeight){ 
     stage.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler); 
     cursor_mc.startDrag(true); 
    } 
}