Cant get the sphere to be displayed.

Software: Away3D 4.x

nickovsky, Newbie
Posted: 28 January 2012 06:00 AM   Total Posts: 3

hi,

i am really new to away3d. i have tried the example but i can not get it work. Here is the code.

package
{
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.primitives.Sphere;
import flash.text.StaticText;
import flash.text.TextField;

import flash.display.Sprite;
import flash.events.Event;
import flash.display.StageAlign;
import flash.display.StageScaleMode;

public class Basic01 extends Sprite
{
  private var scene:Scene3D;
  private var view:View3D;
  private var sphere:Sphere;
  private var textField:TextField;
  public function Basic01()
  {
  scene = new Scene3D();
  view = new View3D(scene);
  view.backgroundColor = 0xFFEEEE;
  this.stage.addChild(view);
  sphere = new Sphere();
  sphere.x = 100;
  sphere.y = 100;
  sphere.radius = 50;
  view.scene.addChild(sphere);
  textField = new TextField();
  textField.x = 50;
  textField.y = 100;
  textField.appendText(“Hello world”);
  this.stage.addChild(textField);
  this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  }
  private function onEnterFrame(ev:Event):void
  {
  sphere.roll(1);
  view.render();
  }
}
}

When i test the project. The view background color is correct.
The text field is displayed correctly both text and position.
But for the sphere, it never shows up. What have i done wrong?

I use FlashDevelop 4.0, Flex SDK 4.6.0(installed by FlashDevelop) and
away3d-core-fp11-f71921f.

Thanks.

   

John Wilson, Member
Posted: 28 January 2012 09:30 AM   Total Posts: 62   [ # 1 ]

Hi,

You need to add a material to the sphere:

sphere = new Sphere();
sphere.material = new ColorMaterial(0xff0000);
sphere.100;
sphere.100;
sphere.radius 50;
view.scene.addChild(sphere); 

Hope this helps.

 

   

nickovsky, Newbie
Posted: 28 January 2012 10:55 AM   Total Posts: 3   [ # 2 ]

Thanks a lot. Now i can see the sphere. But it looks like a filled circle rather than a sphere - -”.

   

Avatar
theMightyAtom, Sr. Member
Posted: 28 January 2012 11:35 AM   Total Posts: 669   [ # 3 ]

try adding some light.
Probably a good idea to go through the examples before hitting the forums

Good Luck!

   

nickovsky, Newbie
Posted: 29 January 2012 01:43 AM   Total Posts: 3   [ # 4 ]

I have tried the examples. But most of them are for the 3.x version.
I have read through them and find out that the 4.x version is quite
different from the 3.x version.
For example, the primitive sphere In the 3.x we can do

var sphere:Sphere = new Sphere({x:200, y:200});

(from the tutorial http://www.flashmagazine.com/Tutorials/detail/away3d_basics_a_simple_away3d_class_explained/)

but gives a compilation error in the 4.x.

From a newbie point of view, the 3.x is easier to get in the Away3d world coz just couple of lines of code we can see a 3d object. But for the 4.x we have know how create 3d object, how to apply material and how to use light so that we can see a proper 3d object.

   

Avatar
theMightyAtom, Sr. Member
Posted: 29 January 2012 06:36 AM   Total Posts: 669   [ # 5 ]

https://github.com/away3d/away3d-examples-broomstick/tree/master/src

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X