Sample C++ libraries running in the browser via Flash Player

Learning by example is always the best way to understand a new tool. So with the FlasCC SDK we ship a number of fully working examples of open source libraries being compiled and used within SWFs. By reading the documentation and investigating these examples you should be able to get a good understanding of how best to use FlasCC.

These projects can be found in the /samples/ folder of the FlasCC SDK which can be downloaded from the Adobe Gaming Tools page.


The Box2D example creates a SWC from the C++ Box2D library. SWIG is used to automate the process of generating all of the wrapper code which is incredibly helpful as it avoids you writing lots of tedious and bug-prone wrapper code by hand. Having the ActionScript API auto-generated like this can be an important timesaver if you need to update the underlying C++ code.

Bullet Physics

Bullet is a large C++ library with roughly 130 thousand lines of code. It is used throughout the industry for both offline and real-time physics simulations. It not only supports basic rigid-body physics, but also more advanced soft-body physics for simulating deformable objects such as cloth. Creating a SWC with an ActionScript API for Bullet is a trivial process and allows ActionScript developers high-performance access to this great library. The demo we ship with the FlasCC SDK shows how to create a simple 3D scene using the Away3D library and how Bullet can be used to provide physical simulation for the objects in the Away3D scenegraph.

Live Demo:


Due to its small size and how easy it is to embed within other environments a lot of people are choosing Lua as their scripting language of choice. The reference implementation of the Lua interpreter is written in C and is designed to be compiled as a library and linked into other projects. As with the other examples we used SWIG here to automatically generate the AS3 bindings. We also write some interop code by hand that reflects the AS3 API into Lua so that Lua programs can be run within the Flash Player and can interoperate with the Flash API set. We wrote a simple real-world example that shows a Starling-based AS3 application that is controlled by a Lua script that can be updated while the SWF is executing.

Live Demo:

Click “Run Script” to execute the Lua script. Note that you can edit the script live and click “Run Script” again to execute your latest changes. For example try changing the line “gravity = 5” to “gravity = 0.01” and click Run Script again to see your changes.

Quake 1

This was the killer demo for the original Alchemy prototype and showed that complex C code could be compiled correctly into a SWF with excellent runtime performance. The game might be old, but it still looks surprisingly good and performs better when compiled with FlasCC than it did with the old Alchemy prototype.

For a more modern killer demo take a look at the FlasCC-compiled Unreal Engine live demo.

3 Responses to Sample C++ libraries running in the browser via Flash Player

  1. Mike Wendorff says:

    I think that this is seriously a great feature. I mean, there have been so many times when I have used programs, not knowing the correct way to do stuff because no examples are available. It is quite irritating actually.

  2. AJ says:

    This is Impressive, But i still didn’t figer out how to do such stuff with flash cc.

  3. HotFix says:

    box2d example is great, but how can i use b2ContactListener? Normally, in C++ I can create custom listener which extends b2ContactListener and pass pointer to b2Word but using flascc it won’t work