Setting up FlashDevelop 4 and Away3D 4

I love to try new toys. By the time this blog is posted, both FlashDevelop4 and Away3D 4 are in beta version, and so does Flash Player 11. I really can’t wait until we have Flash player 11 or AIR 3 on desktop and mobile device 🙂

Here’s what I’ve done to setup FlashDevelop 4 beta with Away3D 4 (assumming that FlashDevelop4 and Flex SDK 4.5.1 have been installed):

Edit (July 2013): This tutorial has been updated for FlashDevelop 4.4.x, Flash Player 11.3, and Away3D 4.1.4.

Setting up Flash Player 11 Beta

Edit (July 2013): this step is not necessary anymore for Flash Player 11.3

  1. Download and install Flash Player 11 beta from here. Choose the IE/activex one (either the release or debugger version) since it’s required by FlashDevelop.
  2. Download globalplayer.swc from here, add it to your FlashDevelop folder (FlashDevelop\Tools\flexlibs\frameworks\libs\player\11.0), also on your Flex SDK folder (FlashDevelop\Tools\flexsdk\frameworks\libs\player\11.0 or FlexSDK\frameworks\libs\player\11.0).

Setting up Away3D 4
Download and install new away3d 4 from https://github.com/away3d/away3d-core-fp11

Setting up A Simple Project

  1. Create a new AS3 project.
  2. On Project Properties, change Platform to Flash Player 11
  3. Add away3D4 as your project lib (from Project Properties > Classpaths, add folder away3d-core-fp11\src)
  4. On Project Properties, add -swf-version=13 to additional compiler options
  5. Now we’re ready to go. We’re going to create a simple rotating cube. Just update your Main.as to:
package
{
    import away3d.containers.View3D;
    import away3d.entities.Mesh;
    import away3d.lights.PointLight;
    import away3d.materials.ColorMaterial;
    import away3d.materials.lightpickers.StaticLightPicker;
    import away3d.primitives.CubeGeometry;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import away3d.debug.AwayStats;

    /**
     * Show me da cube
     * @author Abiyasa
     */
    public class Main extends Sprite
    {
        private var _view:View3D;
        private var _cube:Mesh;
        private var _light:PointLight;
        private var _lightPicker:StaticLightPicker;

        public function Main():void
        {
            // init view
            _view = new View3D();
            _view.backgroundColor = 0xDDDDDD;
            this.addChild(_view);

            // add away3d debugger
            addChild(new AwayStats(_view));

            // init light
            _light = new PointLight();
            _light.x = 0;
            _light.y = -1000;
            _light.z = -1000;
            _light.color = 0xFFFFFF;

            _view.scene.addChild(_light);

            _lightPicker = new StaticLightPicker([ _light ]);

            // create cube with simple color material
            var material:ColorMaterial = new ColorMaterial(0x009EE1);
            material.lightPicker = _lightPicker;
            _cube = new Mesh(new CubeGeometry(100, 100, 100, 4, 4, 4), material);
            _cube.y = 150;
            _view.scene.addChild(_cube);

            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            stage.addEventListener(Event.RESIZE, onStageResize);

            // add event listener
            this.addEventListener(Event.ENTER_FRAME, handleEnterFrame, false, 0, true);
        }

        private function onStageResize(event:Event):void
        {
            _view.width = stage.stageWidth;
            _view.height = stage.stageHeight;
        }

        private function handleEnterFrame(event:Event):void
        {
            // rotate the cube
            _cube.rotationY += 5;
            _view.render();
        }
    }
}
Preview
Rotating Cube on Flash Player 11

Rotating Cube on Flash Player 11

If you have Flash Player 11 installed on your browser, click here to view the cube
Source code
You can download the source code (including the FlashDevelop project file) from here.

5 thoughts on “Setting up FlashDevelop 4 and Away3D 4

  1. Hi
    I’m getting the following errors !
    (20): col: 21 Error: Type was not found or was not a compile-time constant: Cube.
    (44): col: 13 Error: Access of possibly undefined property lights through a reference with static type away3d.materials:ColorMaterial.
    (45): col: 16 Error: Call to a possibly undefined method Cube.
    (6): col: 26 Error: Definition away3d.primitives:Cube could not be found.
    thanks.

    • Thanks, Aman! The error code is due to changes on Away3D library. My code was based on very old version of Away3D.

      I’ll update it as soon as possible 😉

  2. Hello.. I Know this is an old post.. I was looking up how to set up Away3D in Flash develop this helped me with that thank you..But your Source code on this page.. Doesnt create a cube.. And the Code that we can download gives multiple errors which i understand due to Away3D being updated.. Maybe you can update this tutorial?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.