Hi,
I’m a total newbie in flash/flex/away3d world and I’ve lost hours trying to see something in 3D on the screen.
I’m working with Flex 4.6 + Away3D 4.1 and I suspect the problem might be related to Stage3D pixels being printed behind Flash. So, I tried to set backgroundAlpha=“0” to the Application tag, but it keeps printing fully white screen.
The code is like this:
View3D MXML component
<?xml version="1.0" encoding="utf-8"?>
<mx:UIComponent xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%"
height="100%">
<fx:Script>
<![CDATA[
import away3d.containers.View3D;
public var view:View3D;
override protected function createChildren():void
{
super.createChildren();
view = new View3D();
addChild(view);
view.addEventListener(Event.ADDED_TO_STAGE, update);
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
update();
}
private function update(e:* = null):void
{
if (view.stage)
{
view.x = unscaledWidth / 2;
view.y = unscaledHeight / 2;
view.render();
trace("rendered");
}
}
]]>
</fx:Script>
</mx:UIComponent>
Main MXML application
<?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"
xmlns:local="*" creati
backgroundAlpha="0">
<fx:Script>
<![CDATA[
/* imports... */
public function creationComplete():void
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(event:Event):void
{
var plane:Mesh = new Mesh(new PlaneGeometry(90, 90), new ColorMaterial(0x5555FF));
viewComponent.view.scene.addChild(plane);
viewComponent.view.camera.x = -100;
viewComponent.view.camera.y = 100;
viewComponent.view.camera.z = -100;
viewComponent.view.camera.lookAt(new Vector3D());
}
]]>
</fx:Script>
<local:AwayView3D id="viewComponent"/>
</s:Application>
I don’t get any error but the screen is white.
In the Away3D examples I saw they implement everything inside a AS3 class, without any MXML code, but I don’t know if that’s for doing it more readable, or there’s a good reason for that. What’s the best way?
What am I missing? Any help would be appreciated.