FLEX 4.6 / FP 11.2 = NOT WOKING

Software: Away3D 4.x

Lucid, Member
Posted: 24 February 2012 11:11 AM   Total Posts: 93

Flash Builder / Flex SDK: 4.6
Flash Player Version Installed: 11.2
Away3D Version: 4.0 Alpha
Away3D SWC Version targeted: away3d-core-fp11_4_0_0_beta.swc
HTML wmode parameter value:  “direct”

———
This does not work: (would someone care to explain why)


<?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”    applicati>

<fx:Script>
  <![CDATA[
  import away3d.cameras.Camera3D;
  import away3d.containers.Scene3D;
  import away3d.containers.View3D;
  import away3d.entities.Mesh;
  import away3d.materials.ColorMaterial;
  import away3d.primitives.SphereGeometry;
 
  import mx.events.FlexEvent;
 
  // 3D
  private var scene:Scene3D;
  private var camera:Camera3D
  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 {
  scene = new Scene3D();
  camera = new Camera3D();
  view = new View3D();
  view.scene = scene;
  view.camera = camera;
  resize();
  window.addChild(view); }
 
  private function initListen():void {
  addEventListener(Event.ENTER_FRAME,enterFrame);
  stage.addEventListener(Event.RESIZE,resize)}
 
  protected function enterFrame(event:Event):void {
  view.render(); }
 
  protected function resize(event:Event=null):void {
  view.width = stage.stageWidth;
  view.height = stage.stageHeight;
  //camera.position = new Vector3D(0,0,0);
  }
 
  private function initCore():void { 
  var mesh:Mesh = new Mesh(new SphereGeometry(2000,48,48))
    mesh.material = new ColorMaterial(0x0099ff,1)
    mesh.position= new Vector3D(0,0,0)
  scene.addChild(mesh);}
 
  ]]>
</fx:Script>

<fx:Declarations>
  <!—Place non-visual elements (e.g., services, value objects) here—>
</fx:Declarations>

<s:SpriteVisualElement id=“window” width=“100%” height=“100%” doubleClickEnabled=“true”>
</s:Application>

   

Avatar
Matse, Sr. Member
Posted: 24 February 2012 11:31 AM   Total Posts: 149   [ # 1 ]

“Not working” isn’t exactly what I’d call a good problem description wink

I don’t use Flex but unless that changed in the Beta, you don’t need to create a scene or camera : not sure if that’s the problem though.

private function init3D():void {
  view = new View3D();
  scene = view.scene;
  camera = view.camera;
  resize();
  window.addChild(view); }

   

Lucid, Member
Posted: 24 February 2012 11:46 AM   Total Posts: 93   [ # 2 ]

Not Working = completely white.
Also, I’ve modified the code (using only the view3D). And it still does not work. (completely white).

So, this is about as basic as it gets folks. I’m using the latest Flex SDK (4.6.0), the latest version of Away3D (4.0.0 Beta) and the latest version of Flash Player (11.2).

——-


<?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”
    pageTitle=“Lucid Viewer”    applicati>

<fx:Script>
  <![CDATA[
  import away3d.containers.View3D;
  import away3d.entities.Mesh;
  import away3d.materials.ColorMaterial;
  import away3d.primitives.SphereGeometry;
 
  import mx.events.FlexEvent;
 
  // 3D
  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();
  resize();
  window.addChild(view); }
 
  private function initListen():void {
  addEventListener(Event.ENTER_FRAME,enterFrame);
  stage.addEventListener(Event.RESIZE,resize)}
 
  protected function enterFrame(event:Event):void {
  view.render(); }
 
  protected function resize(event:Event=null):void {
  view.width = stage.stageWidth;
  view.height = stage.stageHeight;
  view.camera.position = new Vector3D(0,0,0); }
 
  private function initCore():void { 
  var mesh:Mesh = new Mesh(new SphereGeometry(2000,48,48))
    mesh.material = new ColorMaterial(0x0099ff,1)
    mesh.position= new Vector3D(0,0,0)
  view.scene.addChild(mesh); }
 
  ]]>
</fx:Script>

<fx:Declarations>
  <!—Place non-visual elements (e.g., services, value objects) here—>
</fx:Declarations>

<s:SpriteVisualElement id=“window” width=“100%” height=“100%” doubleClickEnabled=“true”>
</s:Application>

   

Avatar
theMightyAtom, Sr. Member
Posted: 24 February 2012 01:42 PM   Total Posts: 669   [ # 3 ]

You are possibly obscuring the 3D scene with a white background on you “Window”. Remember, GPU 3D renders behind flashes displayList, regardless of where you attach your view.

Good Luck!

   

Lucid, Member
Posted: 24 February 2012 01:55 PM   Total Posts: 93   [ # 4 ]

I have now completely removed the SpriteVisualElement (‘window’) and have attached the View3D directly to the Stage - stage.addChild(view);

Still there is only white. I have also tried various combinations of:
1. setting mesh.bothsides = true
2. setting the Application background alpha to 0

Nothing works. All I get is white.

——————-


<?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”
    pageTitle=“Lucid Viewer”    applicati>

<fx:Script>
  <![CDATA[
  import away3d.containers.View3D;
  import away3d.debug.AwayStats;
  import away3d.entities.Mesh;
  import away3d.materials.ColorMaterial;
  import away3d.materials.TextureMaterial;
  import away3d.primitives.SphereGeometry;
 
  import mx.events.FlexEvent;
 
  // 3D
  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();
  resize();
  stage.addChild(view);
  stage.addChild(new AwayStats(view))}
 
  private function initListen():void {
  addEventListener(Event.ENTER_FRAME,enterFrame);
  stage.addEventListener(Event.RESIZE,resize)}
 
  protected function enterFrame(event:Event):void {
  view.render(); }
 
  protected function resize(event:Event=null):void {
  //view.x=stage.stageWidth/2;
  //view.y=stage.stageHeight/2;
  view.width = stage.stageWidth;
  view.height = stage.stageHeight;
  //view.camera.position = new Vector3D(0,0,0);
  }
 
  private function initCore():void { 
  var mesh:Mesh = new Mesh(new SphereGeometry(2000,48,48))
    mesh.material = new ColorMaterial(0x0000ff,1)
    //mesh.material.bothSides = true;
    mesh.position= new Vector3D(0,0,0)
  view.scene.addChild(mesh); }
 
  ]]>
</fx:Script>

<fx:Declarations>
</fx:Declarations>
</s:Application>

   

Avatar
kurono, Sr. Member
Posted: 24 February 2012 04:20 PM   Total Posts: 103   [ # 5 ]

Try this after initialization:

this.setStyle("backgroundAlpha"0); 

Hope it will resolve your problem smile

Another possibility is that your camera is inside your geometry or view’s clipping has too small range.

   

Lucid, Member
Posted: 24 February 2012 05:42 PM   Total Posts: 93   [ # 6 ]

Setting the background alpha to 0 does not fix the problem. The application only shows pure white.

Considering that I am running the latest versions of Flash Player, Away3D and the Flex SDK, I would say the inability to get a (basic) working setup under these circumstances is troubling to say the least.

   

Avatar
kurono, Sr. Member
Posted: 24 February 2012 06:00 PM   Total Posts: 103   [ # 7 ]

To check is your View3D visible or not, change its background color or fill it with BitmapData

view.backgroundColor = 0xaabbcc;
or
view.backgroundImage = new myAsset().bitmapData;

   

Lucid, Member
Posted: 24 February 2012 06:06 PM   Total Posts: 93   [ # 8 ]

I added:
view.backgroundColor = 0x0000ff;

Still shows only white.

   

Avatar
Matse, Sr. Member
Posted: 24 February 2012 06:10 PM   Total Posts: 149   [ # 9 ]

I took the time to test on my end : I get the white screen too, just the away stats showing up.

Then I tried putting the AS code in a Class extending Sprite and it worked right away, showing a blue sphere over a black background.

No idea what’s going on with the Flex version though as I never worked with Flex and only know some basics about it.

   

Avatar
kurono, Sr. Member
Posted: 24 February 2012 06:30 PM   Total Posts: 103   [ # 10 ]

View3d extends Sprite. Sprite can’t be attached to Flex directly. Flex deals with UIComponent. So, I can share subroutine which can do it.

private function addFlexUIChild(addWhat:DisplayObjectaddTo:UIComponent):UIComponent {
   
var uic:UIComponent = new UIComponent();
   
addTo.addChild(uic);
   
uic.addChild(addWhat);
   return 
uic;
  

To add your view to the Flex container:

addFlexUIChild(viewsomeFlexControl); 

where someFlexControl is, for example, is a Canvas

<mx:Canvas id="someFlexControl" width="100%" height="100%" backgroundColor="0xffffff" /> 

Also, make sure you did this:

someFlexControl.setStyle("backgroundAlpha"0);
view.width someFlexControl.width;
view.height someFlexControl.height

 

   

Lucid, Member
Posted: 24 February 2012 06:55 PM   Total Posts: 93   [ # 11 ]

@ Kurono

I solved the puzzle. It was actually very simple. I replaced the s:SpriteVisualElement with an mx:UIComponent and added the view to the UIComponent. Finally, setting the backgroundAlpha of the Flex Application to 0 allows the Stage3D to show.

grin

   

Avatar
kurono, Sr. Member
Posted: 24 February 2012 07:38 PM   Total Posts: 103   [ # 12 ]

So am I.

   

Stephen Hopkins, Sr. Member
Posted: 24 February 2012 10:32 PM   Total Posts: 110   [ # 13 ]

set the backgroundAlpha of your flex component to 0

 Signature 

http://www-scf.usc.edu/~shopkins

   

Stephen Hopkins, Sr. Member
Posted: 24 February 2012 10:33 PM   Total Posts: 110   [ # 14 ]
Lucid - 24 February 2012 06:55 PM

@ Kurono
Finally, setting the backgroundAlpha of the Flex Application to 0 allows the Stage3D to show.

grin

That is what you needed, SpriteVisualElements work fine.

 Signature 

http://www-scf.usc.edu/~shopkins

   

frogman_pep, Newbie
Posted: 27 February 2012 10:24 PM   Total Posts: 19   [ # 15 ]

Lucid, I’ve been struggling to get this to work, could you post the complete working code?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X