Essent. Guide to 3D in Flash (FOE book)

Software: Away3D 4.x

Energetic Pixels, Newbie
Posted: 14 February 2012 08:15 PM   Total Posts: 2

Ok. I am stumped.  I am working through subject book.  I am in Chapter 6. In the author’s first example where we are drawing 3D vector shapes, I am running into a Flash Compiler error #1061 (call to undefined method).  I am having problems where we use “offset” to push the vector shapes along the x-axis so that both of them are seen side-by-side.  If I comment out both lines where we develop the shape of each (triangle and square), I get both shapes accordingly.  I am using the latest sdk from away3d and Flash CS5.5 is my IDE.  Did away3d move the offset function somewhere else???

Here is the vector shape class:

package  {
 import away3d
.core.base.*;
 
import away3d.materials.*;
 
[SWF(width="800"height="600")]
 
public class SimpleVectorShapes extends SampleBase {
  override 
protected function _createScene():void { 
   
var mesh:Mesh = new Mesh();
   
mesh.bothsides true;
   var 
material:WireColorMaterial = new WireColorMaterial(0xFF0000);
   
material.wireColor 0x000000;
   
material.thickness 2;
   
mesh.material material;

   
_view.scene.addChild(mesh);
   
   
// TRIANGLE object
   
var face0:Face = new Face();
   
face0.moveTo(-50, -500);
   
face0.lineTo(50500);
   
face0.lineTo(-50500);
   
face0.lineTo(-50, -500);
   
face0.offset(-30000);
   
mesh.addFace(face0);
   
// SWUARE object
   
var face1:Face = new Face();
   
face1.moveTo(-50, -500);
   
face1.lineTo(50, -500);
   
face1.lineTo(50500);
   
face1.lineTo(-50500);
   
face1.lineTo(-50, -500);
   
//face1.offset(-180, 0, 0);
   
mesh.addFace(face1);
  
}
 }

and here is the base class:

package  {
 
 import away3d
.cameras.*;
 
import away3d.containers.*;
 
 
import flash.display.*;
 
import flash.events.*;
 
 
[SWF(width="800"height="600")]
 
 
public class SampleBase extends Sprite {
  
  
protected var _camera:Camera3D;
  protected var 
_view:View3D;

  public function 
SampleBase() {
   
   _createView
();
   
_createScene();

  
}
  
  
protected function _createView():void {
   
   _camera 
= new TargetCamera3D();
   
_camera.= -1000;
   
   
_view = new View3D();
   
_view.400;
   
_view.300;
   
_view.camera _camera;
   
addChild(_view);
   
addEventListener(Event.ENTER_FRAME_onEnterFrame);
  
}
  
  
protected function _createScene():void {
   
   
  }
  
  
protected function _onEnterFrame(ev:Event):void {
   
   _camera
.-= (_camera.- (* (mouseX - (stage.stageWidth 2)))) / 4;
   
_camera.-= (_camera.+ (* (mouseY - (stage.stageHeight 2)))) / 4;
   
_view.render();
  
}

 }

I moved from PV3D to Away3D cuz Away3D is more updated and active.  Plus I am trying to convince my company about using 3D objects in the training we develop for our clients.  Any help on my error above would greatly be appreciated.

Tony

 

   

John Brookes, Moderator
Posted: 14 February 2012 09:20 PM   Total Posts: 732   [ # 1 ]

In the old google code svn
svn tags 3.6.0 lib still has offset it but later 3.6 versions dont.


Just opinion, but don’t bother learning 3.6 version and get with 4.

Away now supports GPU with flash player 11. (Away 4 ‘alpha’)
https://github.com/away3d/away3d-core-fp11

Which does make quite a bit of what you read in the book outdated :/

   

Energetic Pixels, Newbie
Posted: 14 February 2012 10:11 PM   Total Posts: 2   [ # 2 ]

John,

  Yah, I know I am working in sort of a round about way (book is version 3.6 and I am trying to use sdk version 4 alpha).  But I am also going to have to teach my fellow flash programmers here in the office on how to do this too.  That is the reason for the book (hard copy), so I can read the chapter a couple of times before I try it in the IDE.
  That being said and since offset has gone away, is there a way to push/position these Faces within the mesh that is created?? I thought about using applyPosition method from the Mesh class, but I still get a 1061 error.  Maybe I am not using it correctly.

Tony

   

John Brookes, Moderator
Posted: 15 February 2012 05:26 PM   Total Posts: 732   [ # 3 ]

erm long time since I’ve done it, maybe loop throught the vertices and add an offset.

As for the book I cant see how it helps with Away4, so much as changed.

For learning about Away4 the examples should help
https://github.com/away3d/away3d-examples-broomstick

Also nicoptere did a nice write up
http://en.nicoptere.net/?p=2047

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X