Level: Beginner Version : 2.0.2 Author : Floris Date : December 27th 2008
This is the AS2 2.0.2 version of the AS3 3.x 3 lines of code tutorial.
Copy and paste this code into a new Flash Document:
import sandy.core.Scene3D; import sandy.core.scenegraph.*; import sandy.primitive.*; // -- creation of the scene. You give it a container, a camera and a root group to add your object into. var scene:Scene3D = new Scene3D( "myScene", this, new Camera3D( 550, 400 ), new Group("root") ); // -- you add an object to the scene you've just created scene.root.addChild(new Sphere( "mySphere" ) ); // -- and you ask the scene to render scene.render();
The AS3 code for this is exactly the same. There's no difference between the codes? That's the joke! Navigate to the version page to see the differences between the AS3 and AS2 2.x versions.
The AS3 3.x tutorial says: Now you may wonder how to apply a texture on that sphere. Before compiling this example, import a bitmap into your Flash file's library. Enable the bitmap's “Export for ActionScript” checkbox and set its Linkage Class name to “Texture”.
Don't set its Linkage Class name to “texture” but its identifier and compile the following code:
import sandy.core.Scene3D; import sandy.core.scenegraph.*; import sandy.primitive.*; import sandy.materials.*; // -- creation of the scene. You give it a container, a camera and a root group to add your object into. var scene:Scene3D = new Scene3D( "myScene", this, new Camera3D( 550, 400 ), new Group("root") ); var sphere:Sphere = new Sphere("mySphere"); // "texture" must match the name of the Linkage Class set for a bitmap in the FLA file's library sphere.appearance = new Appearance( new BitmapMaterial( BitmapData.loadBitmap( "texture" ) ) ); // -- you add an object to the scene you've just created scene.root.addChild( sphere ); // -- and you ask the scene to render scene.render();
This is a basic tutorial, withouth classes, so it's not very different from the AS3 3.x one. When you move on to more interesting tutorials, with more explanations, you need to know more about the differences between 3.x and 2.0.2.
And don't forget to have fun
!