Flash/3D tutorial

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
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

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]

  1. Open Flash CS6.
  2. Create a new ActionScript 3.0 FLA file.

Set the Flash Player to 11 or Above[edit | edit source]

  1. Go to File → Publish Settings.
  2. Under the Flash tab:
    1. Set Player version to Flash Player 11.0 or newer.
  3. 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]

  1. Copy the away3d folder into your project directory.
  2. In Flash CS6:
    1. Go to File → ActionScript Settings.
    2. In the Source path tab:
      1. Add the path to the folder that contains away3d (e.g., ./away3d or ./src).

B: Link Away3D as SWC (if available)[edit | edit source]

  1. If a .swc file is provided, use it instead.
  2. In Flash CS6:
    1. Go to File → ActionScript Settings.
    2. In the Library path tab:
      1. Add the path to the .swc file.

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.