FLEX 4.6 / FP 11.2 = NOT WOKING

Software: Away3D 4.x

BoomerSooner, Newbie
Posted: 28 February 2012 12:34 AM   Total Posts: 5   [ # 16 ]

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>

 

File Attachments
Main.mxml  (File Size: 4KB - Downloads: 0)
   

frogman_pep, Newbie
Posted: 28 February 2012 12:47 AM   Total Posts: 19   [ # 17 ]

Thanks Boomer (U don’t happen to know the wrestling coach, Jared Frayer at OU?)..!

I guess the stars must be aligning cause I was literally cleaning up the code from the original example that I just got to work when you replied. The trouble I didn’t realize, after whenever I got it setup properly, was the SphereGeometry’s radius was set to 3000, and as kurono mentioned the camera must have been inside the geometry.  I guess?

Any ways, for anyone who wants to view the code it took for me to get the original example to work:

<?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"
      
applicationComplete="init(event)">
 
 <
fx:Script>
  <!
[CDATA[   
   import away3d
.containers.Scene3D;
   
import away3d.containers.View3D;
   
import away3d.debug.AwayStats;
   
import away3d.entities.Mesh;
   
import away3d.materials.ColorMaterial;
   
import away3d.primitives.SphereGeometry;   
   
import mx.events.FlexEvent;   
   
   private var 
scene:Scene3D;   
   private var 
view:View3D;
   
   protected function 
init(event:FlexEvent):void{
    
    initPre
();
    
init3D();
    
initListen();
    
initCore();    
   
}
   
   
private function initPre():void{
    
    stage
.scaleMode StageScaleMode.NO_SCALE;
    
stage.align StageAlign.TOP_LEFT;
   
}
   
   
private function init3D():void{
  
    view 
= new View3D();
    
view.backgroundColor 0x000000;
    
view.antiAlias 3;    
    
resize();    
    
stage.addChild(new AwayStats(view));
    
window.addChild(view);
   
}
   
   
private function initListen():void{
    
    addEventListener
(Event.ENTER_FRAMEenterFrame);
    
stage.addEventListener(Event.RESIZEresize);
   
}
   
   
protected function enterFrame(event:Event):void{
    
    view
.render();
   
}
   
   
protected function resize(event:Event=null):void{
    
    view
.width stage.stageWidth;
    
view.height stage.stageHeight;
   
}
   
   
private function initCore():void{
    
    
var mesh:Mesh = new Mesh(new SphereGeometry(3004848));
    
mesh.material = new ColorMaterial(0x0099ff1);
    
mesh.position = new Vector3D(0,0,0);
    
view.scene.addChild(mesh); 
   
}
  ]]
>
 </
fx:Script>
 
 <
mx:UIComponent  id="window"
      
width="100%" height="100%"
      
doubleClickEnabled="true"/>
</
s:Application

Thank you everyone, now it’s time to get Away3Ding cool grin

 

   

ixor3d, Newbie
Posted: 11 March 2013 10:43 AM   Total Posts: 3   [ # 18 ]

This is an old thread but for anyone stumbling for a solution to this the simplest way to go is, open the index.template.html in the html-template folder with the text editor.

After line 47 add the following:
params.wmode = “direct”;

This now runs correctly without the white screen problem.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X