Problem with setCursorPos in Flash - Away3D
I'm making a 1st person shooter for Flash in Away3D, but it seems that setCursorPos isn't working properly. When I call setCursorPos, the cursor moves to the center of the screen, but also triggers a MOUSE_MOVE event. Is this expected behavior? How do I know when the MOUSE_MOVE event is caused by the setCursorPos; or whether it's caused by actual mouse movement? Here is a code sample of what I'm trying to do:
private function onMove(evt:MouseEvent):void {
if (prevY == 0) {
prevY = evt.stageY;
prevX 开发者_高级运维= evt.stageX;
}
mainView.camera.rotate(Vector3D.X_AXIS,evt.stageY - prevY);
}
}
//This triggers a MOUSE_MOVE event, causing this function to be called again.
nativeInterface.setCursorPos(nativeInterface.screenResolution[0] / 2, nativeInterface.screenResolution[1] / 2);
}
I'm not familiar with nativeInterface and setCursorPos. Could you give a few more details ? Is this Away3D or Away3DLite ?
The first thing that comes to mind to separate the two is checking the eventPhase and doing and if statement based on that, if the eventPhase is different depending when/what triggers the event.
HTH
精彩评论