Flash/3D tutorial
From Soyjak Wiki, the free ensoyclopedia
< Flash
![]() |
WARNING: This page was written, in part or in whole, by a SVPER ADVANCED ARTIFICIAL INTELLIGENCE! |
![]() |
"I, for one, welcome our new robot overlords" |
Tutorial 1: How to Add Away3D 4.0 to a Flash CS6 AS3 Project[edit | edit source]
Download Away3D 4.0[edit | edit source]
- Go to the official Away3D GitHub releases page.
- Download the version compatible with Flash Player 11 and Stage3D (Away3D 4.x).
- Example:
away3d-core-fp11-4.0.9.zip
- Example:
Extract and Locate the Source[edit | edit source]
- Unzip the downloaded package.
- You should see:
away3d
folder (main source package).- Possibly examples and other folders.
Create or Open Your Flash CS6 AS3 Project[edit | edit source]
- Open Flash CS6.
- Create a new ActionScript 3.0 FLA file.
Set the Flash Player to 11 or Above[edit | edit source]
- Go to
File → Publish Settings
. - Under the Flash tab:
- Set Player version to Flash Player 11.0 or newer.
- Make sure Script is set to ActionScript 3.0.
Add Away3D Source to Your Project[edit | edit source]
A: Link Away3D as Source Code[edit | edit source]
- Copy the
away3d
folder into your project directory. - In Flash CS6:
- Go to
File → ActionScript Settings
. - In the Source path tab:
- Add the path to the folder that contains
away3d
(e.g.,./away3d
or./src
).
- Add the path to the folder that contains
- Go to
B: Link Away3D as SWC (if available)[edit | edit source]
- If a
.swc
file is provided, use it instead. - In Flash CS6:
- Go to
File → ActionScript Settings
. - In the Library path tab:
- Add the path to the
.swc
file.
- Add the path to the
- Go to
Create Your Main AS3 Class with Away3D[edit | edit source]
package { import away3d.containers.View3D; import away3d.entities.Mesh; import away3d.materials.ColorMaterial; import away3d.primitives.SphereGeometry; import flash.display.Sprite; import flash.events.Event; public class Main extends Sprite { private var view: View3D; public function Main() { view = new View3D(); addChild(view); var material: ColorMaterial = new ColorMaterial(0xFF0000); var sphere: Mesh = new Mesh(new SphereGeometry(100), material); view.scene.addChild(sphere); view.camera.z = -600; this.addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame(e: Event): void { view.render(); } } }
- Save this as
Main.as
, inside the same folder as your fla. - Set your FLA's document class to:
Main
Test[edit | edit source]
- Press Ctrl+Enter to compile and run.
- You should see a 3D object rendered with Away3D.
Notes[edit | edit source]
- Away3D 4.x requires Flash Player 11+ and uses Stage3D.
- Ensure your graphics card supports Stage3D.
- If nothing renders or performance is poor:
- Enable direct rendering.
- Update your GPU drivers.