Away3D is an open-source real-time 3d Flash/Actionscript-based animation framework, and is used to produce stunning visual effects for both games and advertising.

For this tutorial, I wanted to combine the animation features of Away3D with the Blackberry Tablet application framework to produce a very simple animation for the BlackBerry PlayBook!

Requirements:
Away3D Animation framework
BlackBerry Tablet OS PlayBook Simulator
Adobe AIR 2.5
Adobe Flash Builder

Steps involved:
Create a New Flex Project


Set the SDK to the BlackBerry Table SDK

Add Away3D.swc file

Now for a small HelloWorld animation in Away3D:

Let’s create a Torus with a sphere in the center , and make the torus rotate around its X- & Z-axis, and let’s make the center sphere rotate around its X-axis for fun!
2010-11-01_1617-AWAY3D-BLACKBERRY

Animation file:

package
{

import away3d.containers.View3D;
import away3d.primitives.Sphere;
import away3d.primitives.Torus;

import flash.display.Sprite;
import flash.events.Event;

[SWF( width="1024", height="600", frameRate="30")]
public class HelloWorldAIR extends Sprite
{
private var _view: View3D;
private var _sphere:Sphere;
private var _torus:Torus;

public function HelloWorldAIR()
{
// Create a View
_view= new View3D();
_view.x=500;
_view.y=400;

// Create objects to render
_sphere= new Sphere();
_sphere.radius = 40;

_torus= new Torus( {tube: 20});

// Place objects onto the Scene
_view.scene.addChild( _torus);
_view.scene.addChild( _sphere );

//
addChild( _view );
addEventListener( Event.ENTER_FRAME, onEnterFrame );
}

//
private function onEnterFrame( event : Event ):void
{
// Lets rotate the torus around X- and Z- axis
_torus.rotationZ += 5;
_torus.rotationX += 5;

// Lets rotate the Sphere around its X-axis
_sphere.rotationX += 5;

// RENDER THE VIEW
_view.render();
}
}
}

Advertisements