Your friend, Away3D

The natural progression of gaming has classically been towards realism. Players want to feel immersed when they play a game and the best way to achieve this is through a photo-realistic 3D world. 3D games also allow for more innovative and complex gameplay that flash is now capable of. When a game is not restricted to one plane, much grander ideas can be achieved. Although there are many avenues for achieving 3D Gaming in flash, I’m going to focus on Away3D.

What is Away3D?

Away 3D is a free 3D graphics engine for ActionScript 3. The most recent version, Away3D 4, utilizes a computers graphics card to process 3D information, which frees up the CPU to handle the rest of the processing. This significantly improved the speed of 3D Graphics within Flash and increased the amount of objects that could be on the 3D Stage at one time without slowing down.

The Process, Holmes

So! Lets get cookin’. While Away3D comes equipped with library of perfectly good simple objects, its always more fun to build your own assets. The first thing we need to do is get your beautiful 3D Model into a format that flash can understand.

Step 1: Export from Blender. This time, we’ll be exporting a .obj file.

Step 2. Import to PreFab3D.

Step 3. Export as ActionScript file

Making it work with ActionScript 3

Now for the fun part! Here’s how we turn a regular flash stage into a 3D camera:

First, download away3D and flash player 11. Once you’ve got those babies set up, we make our way to the code.

I’m gonna trust that anyone just hopping into this has a basic understanding of setting up an AS3 file, so we’ll skip to the good parts. The first thing a 3D Scene needs is… a scene!

var scene:Scene3D = new Scene3D();

Secondly, we'll need a view and a camera. It is worth noting that there are several types of cameras in Away3D, but for this example we'll be using a SpringCam, because of how it elastically follows a target object.

Bing bang boom, add some actual programming, a little collision and a few more shapes and you’ve got a very simple game!

This was the file I was using to explore design patterns and 3D Flash, so its far from polished, but the basic principles are:

use the arrow keys to move up down left and right across the screen, hit spacebar to move forward in 3D space. The objective is to collect the little red square and drop it off at the sun, but the fun part of the game is smashing into the earth. I hope to continue to develop this in my spare time and to see how far I can push 3D Flash.

Put an egg in your shoe, and beat it.

Time to spread your wings and fly. Have fun exploring the world of 3D in flash! Here are some handy demos for Away3D demos, so please enjoy looking at them: