Showing posts with label Away3D. Show all posts
Showing posts with label Away3D. Show all posts

Sunday, October 10, 2010

Away3D and Flash Builder 4

Flex Builder 4 Flash Sound Flash Video



This four part tutorial was created by Mike Lively.

Creating the Project

First, create a new Actionscript Project to hold your code (File -> New... -> Actionscript Project). In Flex you have the same two options as with Flash, either copy "away3d" and "nochump" folders into your project folder or link to a folder on your filesystem.  If you chose the SVN option or want to link to a folder on your system, follow these steps:

  • Right click the project you just created and select Properties.
  • Select "Actionscript Build Path", click "Add folder..." and browse to the location of the Away3D source code.
  • Click OK to close the dialogue box

Download Away3D

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

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

package
{
import flash.display.Sprite;
import flash.events.Event;
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});
addChild(viewport);

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

viewport.scene.addChild(cube);

this.addEventListener(Event.ENTER_FRAME, renderThis);

}

private function renderThis(e:Event):void {
viewport.camera.rotationY=mouseX/2;
viewport.camera.rotationX=mouseY/2;
cube.rotationX +=1;
cube.rotationY +=1;
cube.rotationZ +=1;
viewport.camera.moveTo(cube.x,cube.y,cube.z);
viewport.camera.moveBackward(500);
viewport.render();
}

}

}

Download Away3D

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

Related Posts Plugin for WordPress, Blogger...