Multiple markers at this line: -1067: Implicit coercion of a value of type away3d.primitives:CubeGeometry to an unrelated type away3d.containers:Objec

Software: Away3D 4.x

Juggernaut, Newbie
Posted: 01 July 2012 12:39 PM   Total Posts: 7
package
{
 import away3d
.containers.View3D;
 
import away3d.materials.BitmapMaterial;
 
import away3d.primitives.CubeGeometry;
 
 
import flash.display.BitmapData;
 
import flash.display.Sprite;
 
import flash.events.Event;
   
 public class 
Away3dApplication1 extends Sprite
 {
  
private var _view:View3D;
  private var 
bmp:BitmapData;
  private var 
mat:BitmapMaterial;
  private var 
cube:CubeGeometry;
  public function 
Away3dApplication1()
  
{
   _view
=new View3D();
   
_view.x=275;
   
_view.y=200;
   
this.addChild(_view);
   
addEventListener(Event.ENTER_FRAME,onEnterFrame);
   
bmp=new BitmapData(200,200);
   
bmp.perlinNoise(200,200,2,Math.random(),true,true);
   
mat=new BitmapMaterial(bmp);
   
cube=new CubeGeometry({ materialmat });
   
_view.scene.addChild(cube);
  
}
  
  
private function onEnterFrame(ev:Event) : void
  {
   _view
.render();
  
}
 }

The above code is showing error in the flash builder editor for these two lines -

cube=new CubeGeometry({ material: mat });

ERROR: Multiple markers at this line:
-1118: Implicit coercion of a value with static type Object to a possibly unrelated type Number.
-cube

_view.scene.addChild(cube);

ERROR: Multiple markers at this line:
-1067: Implicit coercion of a value of type away3d.primitives:CubeGeometry to an unrelated type away3d.containers:ObjectContainer3D.
-cube

Can anybody tell what I am doing wrong here ?

 

 

   

John Brookes, Moderator
Posted: 01 July 2012 01:06 PM   Total Posts: 732   [ # 1 ]

CubeGeometry no longer takes a material.

I think your using an older version of Away4
Make sure you have the latest from git
https://github.com/away3d/away3d-core-fp11

You should add your geometry to a mesh
eg

var planeGeometry:PlaneGeometry = new PlaneGeometry(300300);
var 
waterMaterial:TextureMaterial = new TextureMaterial(new BitmapTexture(new BitmapData(512512true0xee114e57)))

var 
waterMesh:Mesh = new Mesh(planeGeometrywaterMaterial);
scene.addChild(waterMesh); 
   

Juggernaut, Newbie
Posted: 01 July 2012 01:21 PM   Total Posts: 7   [ # 2 ]

What is wrong with this code - _view.scene.addChild(cube);

I am using Away3D 4 beta available at - http://away3d.com/download/ while following the book - “The essential guide to 3D in Flash”.

It seems that the API classes have changed considerably and I am unable to learn following that book. Also I cannot find any mention of book covering the latest Away3D 4 API. Can you suggest any books or tutorials on the current API library ?

   

Richard Olsson, Administrator
Posted: 01 July 2012 03:13 PM   Total Posts: 1192   [ # 3 ]

It is correct that The Essential Guide to 3D in Flash does not cover Away3D 4.0. The book was released more than a year before Away3D 4.0, and handles Away3D 3.x. Things have changed significantly API-wise, but many of the concepts remain the same, so I suggest you keep reading the book, but maybe not make it a priority to type in all of the code examples. Or, you can use the version of the engine that is covered by the book.

To answer your question about that specific line of code, you’re trying to add a CubeGeometry to the scene. That’s not possible. A geometry instance has to be wrapped in a mesh. In Away3D 3.x they were essentially the same, but in Away3D 4.0 they are split up into separate classes to allow you to reuse the same geometry across many meshes, thereby optimizing GPU performance.

There are no books that cover Away3D 4.0 yet, as far as I know.

   

Juggernaut, Newbie
Posted: 01 July 2012 03:26 PM   Total Posts: 7   [ # 4 ]

Is following a book regarding away3D 3.6 give me less pain during my learning path ? Or is 3.6 and 4.0 are way different ? Is there any wiki tutorials available ? Even the tutorials on http://away3d.com/tutorials/ are based on Version 3.X (except the first one) ! Which book should I grab for getting in-depth knowledge about version 4 ?

   

Richard Olsson, Administrator
Posted: 01 July 2012 03:42 PM   Total Posts: 1192   [ # 5 ]

I think you should read the book through, but not actually copy the code examples, just read them. That will give you a general understanding. Then you can start experimenting on your own, or using tutorials that you find online, and the code examples in the away3d-examples-fp11 repository on GitHub.

Like I said, there are no books about Away3D 4.0 yet.

   

Juggernaut, Newbie
Posted: 02 July 2012 07:50 AM   Total Posts: 7   [ # 6 ]

Well, I have decided upon something - I do not know whether it is a good idea or bad idea. Since no books are available that confirms to the Away3D version 4.0 BETA and very little tutorials available based on the recent release, I have decided to downgrade and use Away3D Version 3.6 because there are more tutorials and books available for it. I hope it won’t be very painful to upgrade after few months when the stable release of version 4 will be available (along with more tutorials and books hopefully). What is your opinion on this plan ?

Secondly, I cannot find a download link for the Away3D version 3.6 on the website. Can you please point me to the official download link of Away3D version 3.6 ?

   

Richard Olsson, Administrator
Posted: 02 July 2012 08:37 AM   Total Posts: 1192   [ # 7 ]

Sure, if you feel most comfortable working from a book then that sounds like a valid plan. But there are more than one Away3D 4.0 tutorial online (just Google) and then of course there are the code examples in the away3d-examples-fp11 repository on GitHub, like I mentioned.

To download Away3D 3.6, go here:
http://away3d.com/download/away3d_3.6.0

   

Avatar
Majo, Newbie
Posted: 24 September 2012 08:48 AM   Total Posts: 22   [ # 8 ]

I apologize if this is a major necro-post, but perhaps it would be nice if the codes from the book could be adapted to 4.0 and made available online? I am using the book as well and am running into the same problem.

   

Richard Olsson, Administrator
Posted: 24 September 2012 08:50 AM   Total Posts: 1192   [ # 9 ]

I’m afraid that’s not something that is very likely to happen, or at least not something that me or Rob (my co-author) will find the time to do. Maybe if someone from the community steps up, but I wouldn’t hold my breath.

Like I explained earlier in the thread, you can use the book to learn the concepts of real-time 3D, and then use any Away3D 4.0 tutorial or the examples in the examples repository on GitHub to learn the syntax and API.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X