Hey, I just got this simple example put together using Away3D and the Flex framework. It shows a spinning cube. I also attached the .mxml source file for easier reading/copying/editing.
<?xml version=“1.0” encoding=“utf-8”?>
<s:Application xmlns:fx=“http://ns.adobe.com/mxml/2009”
xmlns:s=“library://ns.adobe.com/flex/spark”
xmlns:mx=“library://ns.adobe.com/flex/mx”
backgroundAlpha=“0” creati>
<s:BorderContainer id=“border” width=“100%” height=“100%” borderColor=“0x000000” borderWeight=“2” backgroundAlpha=“0” >
<s:SpriteVisualElement id=“window” width=“100%” height=“100%” >
<fx:Script>
<![CDATA[
import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.lights.PointLight;
import away3d.materials.ColorMaterial;
import away3d.primitives.Cone;
import away3d.primitives.Cube;
import away3d.primitives.Cylinder;
import away3d.primitives.Sphere;
import flash.display.Stage3D;
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.events.Event;
import mx.core.UIComponent;
// GLOBAL VARIABLE DECLARATION
//define colors
private static const RED:int = 0xCC0000;
private static const LIGHT_RED:int = 0xFFCCCC;
private static const BLUE:int = 0x0000CC;
private static const LIGHT_BLUE:int = 0xCCCCFF;
private static const GREEN:int = 0x00CC00;
private static const LIGHT_GREEN:int = 0xCCFFCC;
private static const YELLOW:int = 0xCCCC00;
private static const LIGHT_YELLOW:int = 0xFFFFCC;
private static const BLACK:int = 0x000000;
private static const WHITE:int = 0xFFFFFF;
private static const GREY:int = 0xAAAAAA;
private static const DARK_GREY:int = 0x222222;
private static const LIGHT_GREY:int = 0x777777;
private static const NEON_PINK:int = 0xCC00CC;
private static const NEON_GREEN:int = 0x66FF00;
//rendering variables
private var view:View3D = new View3D();
private var scene:Scene3D = new Scene3D();
private var camera:Camera3D = new Camera3D();
private var container:ObjectContainer3D = new ObjectContainer3D();
public function start():void {
addEventListener(Event.ENTER_FRAME, onEnterFrame);
initEngine();
initScene();
}
private function initEngine():void {
view.scene = scene;
view.camera = camera;
scene.addChild(container);
view.backgroundColor = LIGHT_YELLOW;
//view.backgroundAlpha = 1;
//view.alpha = 1;
//view.visible = true;
//view.x = 0;
//view.y = 0;
view.height = 700;
view.width = 570;
window.addChild(view);
}
private function onEnterFrame(event:Event):void {
container.rotationX += 2;
container.rotationY += 2;
container.rotationZ += 2;
view.render();
}
private function initScene():void {
var blue:ColorMaterial = new ColorMaterial(BLUE);
var red:ColorMaterial = new ColorMaterial(RED);
var yellow:ColorMaterial = new ColorMaterial(YELLOW);
var green:ColorMaterial = new ColorMaterial(GREEN);
container.addChild(new Cube(red));
var light0:PointLight = new PointLight();
light0.x = -1000;
light0.y = 1000;
light0.z = -1000;
light0.color = WHITE;
var lights:Array = [light0];
blue.lights = lights;
red.lights = lights;
yellow.lights = lights;
green.lights = lights;
scene.addChild(light0);
}
]]>
</fx:Script>
</s:Application>