Real Basic “hello sphere” starter code???

Software: Away3D 4.x

IONaut, Newbie
Posted: 20 October 2011 09:51 PM   Total Posts: 7

Hi everyone, I’m new to Away3d but I’ve been Actionscripting for a couple of years now and I am very excited by the GPU access in the new flashplayer. After doing some research I must say Away3d seems like the obvious choice for a tinkerer like myself. I know all this stuff is pretty new to everyone but there seems to be a complete lack of a real basic “hello sphere” tutorial.

Here’s a code that I modified to work with Away3d 4 using the API reference. It doesn’t throw any compiler errors but it isn’t happy with the render() method right at the end.

import away3d.core.base.*;
import away3d.core.render.*;
import away3d.primitives.*;
import away3d.materials.*;
import away3d.core.*;
import away3d.containers.*;
import away3d.cameras.*;
import flash.filters.BitmapFilterQuality;import flash.filters.BitmapFilterType;
import flash.filters.GlowFilter;


var 
scene:Scene3D = new Scene3D();
var 
camera:SpringCam = new SpringCam();
var 
renderIt:DefaultRenderer = new DefaultRenderer();
var 
view:View3D = new View3D(scenecamerarenderIt);
var 
material = new MaterialBase();
var 
globe:Sphere = new Sphere(material42323true);
camera.target globe;
view.scene.addChild(globe);
view.render(); 

And it outputs:

[SWF] Earth 3d.swf - 217309 bytes after decompression
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at away3d.containers::View3D/updateBackBuffer()[C:\Users\Eric\Documents\learning 3d\src\away3d\containers\View3D.as:351]
at away3d.containers::View3D/render()[C:\Users\Eric\Documents\learning 3d\src\away3d\containers\View3D.as:361]
at Earth3d_fla::MainTimeline/frame1()[Earth3d_fla.MainTimeline::frame1:20]
[UnloadSWF] Earth 3d.swf
Test Movie terminated.

Can anyone tell me what I did wrong? I think a working version of this code would be exactly what every newbie is looking for.

BTW - I’m in Flash 5.5 with AIR 3 overlayed on 2.6

   

Richard Olsson, Administrator
Posted: 21 October 2011 06:50 AM   Total Posts: 1192   [ # 1 ]

Seems like you may have forgotten to add your View3D to the stage.

   

IONaut, Newbie
Posted: 23 October 2011 11:39 PM   Total Posts: 7   [ # 2 ]

Thank you, now I see. Now I get this:

Error #2044: Unhandled ErrorEvent:. text=Error #3702: Context3D not available.

What is Context3D?

   

2smacks, Newbie
Posted: 24 October 2011 12:14 AM   Total Posts: 9   [ # 3 ]

This mean you don’t use the right playerglobal.swc to compil your swf, or your debugger is not the flash player 11 debugger.

   

Avatar
80prozent, Sr. Member
Posted: 24 October 2011 12:16 AM   Total Posts: 430   [ # 4 ]

hi

make shure that the wmode=“direct” is set in your html. otherwise the browser cant handle the new Stage3D.

two other things in your code that could make problems.

apply a ColorMaterial to your sphere, not a MaterialBase.

change the cameras position. you will not see the sphere if your camera is at the same place.

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

IONaut, Newbie
Posted: 24 October 2011 05:38 PM   Total Posts: 7   [ # 5 ]

You guys are great. I’ll try all this post haste. If I’m trying to compile in air 3 what debugger do I need?

   

mb85, Newbie
Posted: 24 October 2011 08:19 PM   Total Posts: 14   [ # 6 ]

This tutorial shows how to set up a simple scene where you load in an external model.

http://www.adobe.com/devnet/flashplayer/articles/creating-games-away3d.html

So far this is the ONLY Away3d 4 tutorial I’ve found that actually works when compiled with the latest FP 11 player. Any others either produce compiler errors, or they simply result in a completely blank view. I’m wondering why this tutorial is on Adobe’s site and not the Away3d site? With the release of Flash Player 11, developers like me are scrambling for information about Stage3D engines. Away3D isn’t doing itself any favors by having a completely blank tutorials page.

   

FlashDev2007, Newbie
Posted: 28 October 2011 09:26 AM   Total Posts: 4   [ # 7 ]

I guess the Away3D team are working really hard to get Away3d 4.0 released. Hopefully when it is released the api docs and examples will all be updated, seems pointless doing all that when the build is a moving target.

I do agree that more tutorials are needed otherwise only the hardcore who can pick their way through code will prosper with this library, without good docs and examples the library is in danger of being superseded.

Anyway I have faith in these guys and after seeing them at FOTB this year I think they are going to do a great job, its a community afterall we can all share our tutorials.

   

IONaut, Newbie
Posted: 13 December 2011 09:55 PM   Total Posts: 7   [ # 8 ]

So useing the basic tutorial for Away3d 4 in the tutorials section (which is the same one suggested earlier in this thread) and adapting it to Flash pro 5.5 I’ve got this code being compiled for flashplayer 11:

import away3d.core.base.*;
import away3d.core.render.*;
import away3d.primitives.*;
import away3d.materials.*;
import away3d.core.*;
import away3d.containers.*;
import away3d.cameras.*;
import away3d.loaders.*;
import away3d.events.*;
import away3d.loaders.parsers.Parsers;
import flash.filters.BitmapFilterQuality;
import flash.filters.BitmapFilterType;
import flash.filters.GlowFilter;

var 
_view:View3D = new View3D();
var 
_loader:Loader3D = new Loader3D();

function 
GettingStartedWithAway3D()
{
 _view
.backgroundColor 0x666666;
 
_view.antiAlias 4;
 
 
this.addChild(_view);
 
this.addEventListener(Event.ENTER_FRAMEonEnterFrame);
 
 
Parsers.enableAllBundled();
 
 
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
 
_loader.addEventListener(LoaderEvent.LOAD_ERRORonLoadError);
 
_loader.load( new URLRequest('vase.awd') );
}

function onLoadError(ev LoaderEvent) : void
{
 trace
('Could not find'ev.url);
 
_loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
 
_loader.removeEventListener(LoaderEvent.LOAD_ERRORonLoadError);
 
_loader null;
}

function onResourceComplete(ev LoaderEvent) : void
{
 _loader
.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
 
_loader.removeEventListener(LoaderEvent.LOAD_ERRORonLoadError);
 
_view.scene.addChild(_loader);
}

function onEnterFrame(ev Event) : void
{
 _loader
.rotationY stage.mouseX stage.stageWidth/2;
 
_view.camera.* (stage.mouseY stage.stageHeight/2);
 
_view.camera.lookAt(_loader.position);
 
_view.render();
}

GettingStartedWithAway3D
(); 

and the output I get is this:

VerifyError: Error #1014: Class flash.display3D.textures::Texture could not be found.

at Earth3d_fla::MainTimeline/frame1()

Do I not have my system set up right? Is it the wrong .swc? I am able to select flashplayer 11 in my “Publish Settings” dialog. I have Away3d src folder as well as the vase.awd file in my root folder. What gives?

   

Albert, Newbie
Posted: 14 December 2011 07:30 AM   Total Posts: 16   [ # 9 ]

I got the “Texture” error when I forgot to add the compiler setting “-swf-version=13”. I do however not know how to add it in Flash 5.5.

   

IONaut, Newbie
Posted: 15 December 2011 03:07 AM   Total Posts: 7   [ # 10 ]

Sweet, I’ll check it out.

   

IONaut, Newbie
Posted: 21 December 2011 08:22 PM   Total Posts: 7   [ # 11 ]

So, it turns out, after all that, that due to a lack of instruction as to the installation of the new flash player 11 features into flash pro 5.5 i had to try to adapt the installation procedure from flash builder. one thing you need to do that is never mentioned anywhere is switch your Hardware Acceleration setting in flash publish settings to “2-GPU”. Now everything seems to work fine.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X