I was able to get a cross-platform mobile 3D solution working, and it wasn’t what I expected it to be. In my current task of creating a mobile application, I found AIR+Flex Mobile to be a pleasure to work with, using tools that I already had available to me. The ViewNavigator was very pleasant, and abstracted mobile “stack”-style navigation very well.

Next on my list was 3D—would Stage3D pan out? As it turns out, AIR 3.1 (the latest) for mobile devices did not support it yet; how disappointing. Then I found out that 3.2 RC1 is released and is the first version that will support it. So here I am, at the cutting edge. Supposedly 3.2 will be out any minute now.

So let’s get a start while we’re ahead of the game here, and be the first ones to beat down this path! I’ll assume that you’re using Flash Builder, but if you’re using Flash Develop I am sure similar instructions apply. I’ll also assume that you can google all of these things if you need more details, sorry I’m so lazy!

To begin with, you’ll need to grab a copy of the Flash Builder 4.6, which is a free download to CS5.5 owners and includes the Flex 4.6 SDK. Next you’ll need to grab a copy of the AIR 3.2 RC1 SDK and overlay it onto the Flex 4.6 SDK. I recommend copying it to 4.6.0_AIR3.2RC1 and then extracting the AIR SDK on top of it, and creating a separate SDK location in FB. You’ll also need to download AIR 3.2 RC1 onto your mobile device(s). 

From here I’ll assume that you can figure out the Away3D samples and cobble together some code that should work. I’ll skip that part and just give you some pointers about things that I stumbled over.

  • Make sure you’re using Away3D 4.0, because it is a re-write for Flash 11 / Stage3D. It wasn’t immediately clear to me, since I’d never touched Flex and have little experience with Flash, and had no idea when Stage3D came around.
  • Some people say you need to add -swf-version=15 to the compiler options and do some things with playerglobals.swc, but I don’t need to with Flex Builder 4.6/AIR 3.2 RC1 SDK—your mileage may vary.
  • In order to use an Away3D instance on a Flex View, you need to set backgroundAlpha=”0” on its parent View.
  • View3D is a Sprite and some people give really convoluted solutions to adding one to the View, like creating UIComponent wrappers. Ignore all of this, and just put it in a SpriteVisualElement!
  • Some people give really convoluted solutions to setting the View3D size, also ignore it. Just set view.width / view.height, but make sure to assign them before you add it to the parent SpriteVisualElement. 
  • The problem that tripped me up most was removing the 3D context from the screen when I navigated to a new View. It would cause my application to stop working correctly and never recover, even if I went back home and back into my app—the only thing that fixed it was to re-install it from FB (via Run). Use view.dispose() from the Event.REMOVED_FROM_STAGE event of the View.

I may or may not post a simple skeleton project on GitHub, depending on interest.