Sunday, October 10, 2010

Using Images in a Cube in Away3D

Flex Builder 4 Flash Sound Flash Video

Creating and Texturing a Cube.

Tween example is from Active Tuts

We will create a cube using the Away3D engine. You can also use images on the cube's faces and make the cube rotate.

  • Create a new ActionScript file and Flash AS3 file
  • Name the ActionScript MyCube and enter the name in the FLA document class
  • Place the Away3D engine in the same directory

Creating the class

import flash.display.Sprite;
import flash.display.Bitmap;

import away3d.cameras.*;

import away3d.containers.View3D;
import away3d.primitives.Cube;
import away3d.materials.BitmapMaterial;

import away3d.core.utils.Cast;

public class MyCube extends Sprite {
private var viewport:View3D;
private var cube:Cube;
//The source image can not be from a URL and must be local
[Embed (source="skin.jpg")] private var myTexture:Class;
private var myBitmap:Bitmap = new myTexture();

public function CreateCube01() {

viewport = new View3D({x:200, y:200});

var myMaterial:BitmapMaterial = new BitmapMaterial(Cast.bitmap(myBitmap));
cube = new Cube({width:150, height:150, depth:150, material:myMaterial});


this.addEventListener(Event.ENTER_FRAME, renderThis);


private function renderThis(e:Event):void {;;
cube.rotationX +=1;
cube.rotationY +=1;
cube.rotationZ +=1;,cube.y,cube.z);;



Download Away3D

Download latest tween engine. (Version 2.5.2 / 3.6.0)
More Away 3D Tutorials.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...