纳金网
标题:
Flash3D编程技巧_全景浏览的鼠标交互
[打印本页]
作者:
铁锹
时间:
2012-11-30 17:14
标题:
Flash3D编程技巧_全景浏览的鼠标交互
1. 注册侦听器
Java代码
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
2. MouseDown触发函数
Java代码
// 保存鼠标点击的摄像机参数和鼠标坐标信息
private function onMouseDown(event:MouseEvent):void
{
lastPanAngle = camera.panAngle;
lastTiltAngle = camera.tiltAngle;
lastMouseX = stage.mouseX;
lastMouseY = stage.mouseY;
move = ***e;
stage.addEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
// 保存鼠标点击的摄像机参数和鼠标坐标信息
private function onMouseDown(event:MouseEvent):void
{
lastPanAngle = camera.panAngle;
lastTiltAngle = camera.tiltAngle;
lastMouseX = stage.mouseX;
lastMouseY = stage.mouseY;
move = ***e;
stage.addEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
3. MouseUp触发函数
Java代码
private function onMouseUp(event:MouseEvent):void
{
move = false;
stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
private function onMouseUp(event:MouseEvent):void
{
move = false;
stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
4. 每帧都调用的onEnterFrame
Java代码
private function onEnterFrame(event:Event):void
{
if (move) {
camera.panAngle = 0.3*(stage.mouseX - lastMouseX) + lastPanAngle;
camera.tiltAngle = 0.3*(stage.mouseY - lastMouseY) + lastTiltAngle;
}
camera.hover();
view.render();
}
private function onEnterFrame(event:Event):void
{
if (move) {
camera.panAngle = 0.3*(stage.mouseX - lastMouseX) + lastPanAngle;
camera.tiltAngle = 0.3*(stage.mouseY - lastMouseY) + lastTiltAngle;
}
camera.hover();
view.render();
}
更多Flash3D编程技巧分享尽在Web3D纳金网http://www.narkii.com/
作者:
89684598
时间:
2014-2-22 15:20
好东西啊,感谢分享
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5