Build Flash 10.1 applications with Flex Builder 3 or Flash Builder 4
It was one of my first posts on this blog: Work with Flash 10 in Flex Builder 3. This post has proven to be very helpful and is still read a lot every day!
As Flash 10.1 is currently accessible in beta. I thought it would be nice to have some tutorial to build applications targeting this new version of the player to take advantage of the new APIs (like multitouch for example). This tutorial will provide a generic solution to enable the creation of Flash 10.1 capable projects in both Flex Builder 3 and Flash Builder 4.
Step 0: Download the latest Flex SDK
This step is not mandatory and should not be necessary if you already have a Flash 10 capable Flex SDK. Still, keeping your SDK up to date is always a good thing and this tutorial might be a good opportunity to do it!
As the Flex 4 SDK was just released a few days ago, I recommend you download, install and use it for the rest of the tutorial.
In the rest of the tutorial, $SDK_DIR will designate the path to the Flex SDK you want to use (ie. "C:\Program Files\Adobe\Flash Builder 4\sdks\4.0.0" for example).
Step 1: Download and install playerglobal.swc
- Go to $SDK_DIR\frameworks\libs\player and create a new folder called "10.1"
- Download the new Flash 10.1 capable playerglobals.swc library from Adobe Labs
- Extract playerglobals.swc from the downloaded ZIP file to the new "10.1" directory you just created
Step 2 : Setup your Flash 10.1 project
- Open Flash Builder 4
- Create a new Flash/Flex project or open the project you want to setup
- Open the properties of your project (right click on your project in the Package Explorer > Properties)
- If you are using Flash Builder 4, go to the "ActionScript compiler" panel and in the "Adobe Flash Player options" section, check "Use a specific version" and enter 10.1.0 as the version number
- If you are using Flex Builder 3, go to the "Flex compiler" panel and in the "Additional compiler arguments" text input add "-target-player=10.1.0"
- Click "OK"
Step 3 : Build your project
Press F11 to build and run your project. Everything should work fine and you should now be able to use the new Flash 10.1 APIs!
You can now create as much projects as you want and you just have to do Step 2 to make sure it will target Flash 10.1!
Frustum Culling in Flash 10
Update: corrected a few glitches in the bounding sphere creation routine.
Optimization is always important. But when it comes to 3D for the Flash Platform, it's an everyday battle. The first ideas that come to mind are to avoid:
- redrawing the same regions : each pixel value must be set once and only once
- rendering invisible objects : objects that are out of sight still take a lot of CPU horsepower
While Flash takes care of the first one in its very renderer, the second one is not handled. But that is something we can easily address!
The Technic
The method is called "frustum culling". The big picture is that every mesh is approximated using a bounding volume (typically a sphere or a box). If the bounding volume is visible, the corresponding mesh is rendered. The two following pictures show the frustum culling caught in action:
