简体   繁体   中英

StartDrag() AS3 Annoying Snap

I'm working on adding a custom cursor in AS3 via startDrag() . On a mac, it works fine. You rollover your flash file and the custom MC snaps to the mouse. On a pc, on load, the cursor immediately jumps to wherever your mouse is OUTSIDE the flash file. A good example to test is this:

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

Try to refresh this page on a pc vs. mac and you'll see the initial position of that cursor to be different. On PC it jumps. How do I resolve? Thank you,

Jan

You could try delaying the drag until after a mouse move event that is in bounds of the stage.

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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM