Flash Stage 3D is out!

A couple of days ago, Adobe released to the masses a new version of their Flash Player, and an updated SDK. The biggest change (for me at least) is the inclusion of hardware-accelerated 3D, known as Stage3D. Here’s a quick tour of what I did to compile and run my first Stage3D program (Windows 7 PC but should be applicable everywhere). Useful because the Adobe site is not really clear about this.

  • Make sure you have a Java runtime installed, you need it for the Flash compiler.
  • Download Flash SDK 4.5.1 from http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK. Extract to a folder (I will assume flex_sdk_4.5.1).
  • Download the appropriate versions of the debug, standalone and plugin Flash Player 11 from http://www.adobe.com/support/flashplayer/downloads.html.
  • While you’re there, download the latest Flash Runtime library.
  • Inside the folder flex_sdk_4.5.1/frameworks/libs/player/ create a folder “11.0“. Copy the playerglobal11_0.swc you just downloaded inside that folder, and rename it to playerglobal.swc. Result:
    flex_sdk_4.5.1/frameworks/libs/player/11.0/playerglobal.swc.
  • Create your working folder, and copy the rotating cube example from the Adobe docs into a file called Context3DExample.as.
  • Delete line 59: this.stage.nativeWindow.activate(); //AIR only and also remove the third “false” parameter from the calls to assemble() from lines 70 and 71.
  • Download the Flash Platform SDK as a ZIP file. Extract the contents of “src” in your work folder. This should result in a folder called “com” side by side with the file “Context3DExample.as“.
  • Compile the sample: flex_sdk_4.5.1/bin/mxmlc -static-link-runtime-shared-libraries -swf-version=13 -target-player=11.0 Context3DExample.as. Note the swf-version and target-player parameters.
  • Run the resulting SWF file with the standalone player 11 you downloaded, or embed it inside a web page. Important: for Stage3D to work properly on hardware, you must add the parameter <param value=”direct” name=”wmode”> to the swf <object> tag, and the attribute wmode=”direct” to the <embed> tag.

The result should be a spinning cube like this (only visible if you have the updated plugin):

[kml_flashembed publishmethod=”static” fversion=”11.0.0″ movie=”/Jare/files/Stage3D/Test3D.swf” width=”320″ height=”240″ targetclass=”flashmovie” wmode=”direct”]

Get Adobe Flash player

[/kml_flashembed]

Further reading and links:

Happy 3D’ing!

8 thoughts on “Flash Stage 3D is out!

  1. Hi,
    i tried to set up in FlashDevelop. It works only when i’m compiling it give the “VerifyError: Error #1014: Class flash.display::Stage3D could not be found.” error, even it does recognize the Stage3D class. In FDT3.5 after almost a half day of trying i can not manage to setup the new SDK. :S
    Do You have any tips?

  2. Did you try to compile the sample with the command line I gave? If that doesn’t work then something may be wrong in your SDK setup.

    That error suggests that it is not building against the version 11.0 of Flash Runtime Library (the swc file). Did you change that in the project settings? I was using FlashDevelop 4 RC1 – it is possible that Flash Develop 3.5 does not include 11.0 as an option? If that’s the case, an option is that you replace the existing swc for 10.2 in the SDK with the downloaded swc for 11.0. Keep a copy of the previous file!

    • Nope, i tried to compile with mxmlc, but it gave me the same error. Could be possible that there are some issues with the downloaded SDK? I’m using the last SDK 4.5.1.21328 (Milestone build). Everything else was set up correctly, even more in Flash Develop framework the auto-completion function works flawlessly, does recognize Stage3D instantaneously, which indicate the Runtime Library is set up correctly. So i have no idea.

  3. I’m sorry esimov, I don’t know what the problem may be. I’ve done this process on two separate machines, one Windows and one Linux, without any problems.

    The error you describe should happen at runtime not at compile time. Is that the case? If so, you must be linking with other libraries besides the Flash Runtime – I’ve never dealt with that problem, but I’ve read (for example here) that you will have to reorder them to avoid the problem.

  4. Hi,

    I tried that code sample it works fine … I also tried to load an image and add it as child, and it works fine too. However whenever I try to convert said image into a Bitmap, the image is not shown, it’s like if the program stopped at the line where I do that … Which can be the solution? Thanks.

    …….
    …….
    …….

    //Add event listener before requesting the context
    stage3D.addEventListener( Event.CONTEXT3D_CREATE, contextCreated );
    stage3D.addEventListener( ErrorEvent.ERROR, contextCreationError );
    stage3D.requestContext3D( Context3DRenderMode.AUTO );

    //Compile shaders
    vertexAssembly.assemble( Context3DProgramType.VERTEX, VERTEX_SHADER);
    fragmentAssembly.assemble( Context3DProgramType.FRAGMENT, FRAGMENT_SHADER);

    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    loader.load(new URLRequest(“sol.jpg”));
    }

    public function loadComplete(e:Event):void {
    var b:Bitmap = Bitmap(loader.content); //when I run this line the addChild() below DOES NOT WORK, WHY ??
    addChild(loader);
    }

  5. Hello

    I have some experience programming with AS but none with Away3d. Can anyone out here help me install this library on Flashdevelop? I have tried but no luck so far. Any help would be greatly appreciated.

  6. Hello!
    How do compile the sample file(I mean Context3DExample.as), what program you use, how is it on Mac? Thanks!

Comments are closed.