Strange error about View3D and CameraHover3D

Software: Away3D 3.x

Kissa, Newbie
Posted: 10 October 2011 12:43 PM   Total Posts: 4

Hello,
Somebody could explain me that strange error I don’t understand.
The following code is ok :

package{
 import flash
.display.Sprite;
 
import away3d.containers.View3D;
 
import away3d.cameras.HoverCamera3D;
 
 public class 
HoverCam extends Sprite{
  
private var view=new View3D();
  
  public function 
HoverCam(){
   view
.camera=new HoverCamera3D();
   
view.camera.hover();
  
}
 }

But if I specify the type of view:

private var view:View3D=new View3D(); 

I get the error that method hover() is not defined, why ?!

 

   

Avatar
Fabrice Closier, Administrator
Posted: 10 October 2011 07:24 PM   Total Posts: 1265   [ # 1 ]

Probably because the getter do not return a type HoverCamera3D but Camera3D. So either you declare a class var myHovercam:HoverCamera3D = new HovrCamera3D and assign it to the view. view.camera = myHovercam. You can then say myHovercam.hover(); or cast to the type. (view.camera as HoverCamera3D).hover();

   

Kissa, Newbie
Posted: 10 October 2011 08:39 PM   Total Posts: 4   [ # 2 ]

You’re certainly right, I didn’t think about this reason.
Thank you for the explanation smile

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X