Problem with MouseEvent3D trigerring

Software: Away3D 4.x

aeki, Member
Posted: 10 November 2012 11:21 AM   Total Posts: 73

I am trying to develop a simple application with away3D and i am having problem with how the MouseEvent3D events trigger.

The structure of my code is simple. I have 2 classes :
  > the main class is “MainApplication”.  In this class i simply initialize an object called Viewer3D defined by a personnal class myAway3DViewer. Then i add the standard mouse listeners MOUSE_DOWN and MOUSE_WHEEL

  > the class myAway3DViewer which takes care to setup3DEngine + load the 3D objects and adding MouseEvent3D to the loaded objetc.

I have a problem with the triggering of the MouseEvent3D.MOUSE_OVER and MouseEvent3D.MOUSE_OUT events. When the mouse is over an object and doesn’t move, MouseEvent3D.MOUSE_OVER and MouseEvent3D.MOUSE_OUT trigger successively indefinetly and causing flickering.

I must miss something with the basics of flash. Any idea of what i am doing wrong.

Here is a simplified version of my code

For the MainApplication class

public class MainApplication extends Sprite
 {  
  
private var Viewer3D:myAway3DViewer
  
    
  
public function MainApplication()
  
{
   super
();
   
   
// 3DViewer
    
Viewer3D = new myAway3DViewer();
   
Viewer3D.init();
   
addChild(Viewer3D);
       
   
Viewer3D.loadAnObjectInScene(new URLRequest('3D Model/Teapot9/Teapot9.awd'));
   
   
// Mouse listeners
   
stage.addEventListener(MouseEvent.MOUSE_DOWNonMouseDown);
   
stage.addEventListener(MouseEvent.MOUSE_UPonMouseUp);
   
   
   
// Setup render enter frame event listener
   
stage.addEventListener(Event.ENTER_FRAME,onEnterFrame);   
  
}
  
  
// Mouse Listeners ///////////////
  
private function onMouseDown(event:MouseEvent):void
  {
   
// some code for mouse interaction with 3D viewer
  
}
  
  
private function onMouseUp(event:MouseEvent):void
  {
   
// some code for mouse interaction with 3D viewer
  
}
  
  
private function onStageMouseLeave(event:Event):void
  {
   
// some code for mouse interaction with 3D viewereMouseLeave);
  
}
  
  
  
// EnterFrame Listeners //////////
  
private function onEnterFrame(e:Event):void
  { 
   
if (Viewer3D.view3D != null){
    Viewer3D
.view3D.render();
   
}
                 }

For the myAway3DViewer class

public class myAway3DViewer extends Sprite
 {
  
  
public var camera3D:Camera3D;
  public var 
scene3D:Scene3D;
  public var 
cameraController:HoverController;
  public var 
view3D:View3D;

  
  public function 
myAway3DViewer()
  
{
   super
();
  
}
  
  
public function init():void{

   
// setup 3D Engine
   
_setup3DEngine();
   
   
_setupLights();
  
  
}
    
  
public function loadAnObjectInScene(anURLRequest URLRequest):void
  {        
   AssetLibrary
.load(anURLRequest,null,null,new AWDParser);
  
}  
  
  
//////////////////////////////////
  // LISTENERS
  ////////////////////////////////// 
  
  // MeshMouse Listeners ///////////////
  
private function onMeshMouseOver(event:MouseEvent3D):void
  {   
   trace
('myAway3DViewer : onMeshMouseOver : ');
  
}
  
  
private function onMeshMouseOut(event:MouseEvent3D):void
  {   
   trace
('myAway3DViewer : onMeshMouseOut : ');

  
}  
  
  
//////////////////////////////////
  // PRIVATE FUNCTIONS
  //////////////////////////////////

  
private function _setupLights():void
  { 
   
// some code....
   
  
}

  
private function _setupMeshMouseListenersmesh:Mesh ):void {
   mesh
.addEventListenerMouseEvent3D.MOUSE_OVERonMeshMouseOver );
   
mesh.addEventListenerMouseEvent3D.MOUSE_OUTonMeshMouseOut );
  
  
}

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X