Hi vkt!
no error on your code, it works like your logic rule,
indeed, here we have a problem of logic.
If you try to catch with addOnMouseMove the Z coord on the sphere to
move the sphere itself you can't drag correctly,
you must have a plane under the sphere and catch the mouse move on the
plane (remeber to turn off the disable the mouse on the sphere)
hope it helps.
-Beka Master
On 1 Set, 16:18, vkt <[EMAIL PROTECTED]> wrote:
> hi,some one ask me how to drag obj in the scence.
>
> here is my code
>
> ///////
>
> private function init(){
> buildEngine()
> buildObject()
> eventListener()
> }
>
> private function buildEngine(){
> scene= new Scene3D();
> camera = new HoverCamera3D({zoom:2,
> focus:200, distance:400});
> camera.targetpanangle = camera.panangle =
> -180;
> camera.targettiltangle = camera.tiltangle =
> 15;
> camera.yfactor = 1;
> view= new View3D({scene:scene,
> camera:camera});
> view.mouseZeroMove=true;
>
> c3d.rawChildren.addChild(view);
> view.x = screen.width/2;
> //
> view.y = screen.height/2;
> c3d.rawChildren.addChild(view);
> systemManager.stage.quality="low";
>
> }
>
> private function buildObject(){
> scene.addChild(new Trident(2000));
> var sp2:Sphere=new Sphere()
> scene.addChild(sp2);
> sp2.addOnMouseDown(canMove);
> sp2.addOnMouseUp(canNotMove);
> sp2.addOnMouseMove(checkMove)
> FPS.init(systemManager.stage);
> }
> private function eventListener(){
>
> addEventListener(Event.ENTER_FRAME,renderView);
>
> addEventListener(ResizeEvent.RESIZE,onResize);
> }
>
> private function renderView(event){
> view.scene.updateTime();
>
> camera.hover();
> view.render();
> }
>
> private function onResize(event){
> view.x = screen.width/2;
> view.y = screen.height/2;
>
> }
>
> private var moveSnap:Boolean=false;
>
> private function canMove(event:MouseEvent3D){
> moveSnap=true;
>
> }
>
> private function
> canNotMove(event:MouseEvent3D){
> moveSnap=false;
>
> }
> private function
> checkMove(event:MouseEvent3D){
>
> if(moveSnap){
> event.object.x=event.sceneX;
> event.object.z=event.sceneZ;
> trace([event.sceneX,event.sceneZ])
> }
> }
> /////////
>
> and the result swf is here.
>
> http://mycofe.cn/3d/dragTest.swf
>
> This is obviously wrong
>
> Z coordinate axis is not rihgt.
>
> I try to like this.
> but the reslut is same as before.
>
> scene.addOnMouseMove(checkMove)
>
> anyOne who can To solve this problem?
>
> thanks.
>
> and I have another question .
>
> It seem to addOnMouseMove(checkMove) not work? why?