Flash/Actionscript3.0 and C/C++ applications or libs

May 7, 2010

In the last days, I worked in a way to link Flash/Actionscript3.0 and C/C++ applications or libs. There are different ways to do it but each with its limitations.

1)  Just code directly your Actionscript inspired in other C/C++ application or libs.

The main advantages of this method are: “it is your code”, you know how it works, you know how to improve it and is all Actionscript.

The main disadvantages are: the hard work used  to code a “new” application and to keep the code updated with new algorithms.

One example is the Marilena Object Detection, a AS3 lib inspired in OpenCV code, for object detection and face recognition.

2) Use the Adobe Alchemy. Alchemy is a tool that enables you to compile C/C++ code into ActionScript 3.0 as a SWF or SWC that runs on Adobe Flash Player 10 or Adobe AIR 1.5.

The main advantage is you do not have to code all from scratch like in 1).

The main disadvantages are: you have to adapt your C/C++ code in a way that Alchemy tool recognizes it, witch can be hard work for long applications or libs; if the C/C++ is not yours it is hard to keep the code updated and it only works on GNU environments (MAC OS, LINUX, Cygwin for Windows ).

Example: Some libs available by Adobe.

3)Use HTTP protocol. Since Actionscript is a Web-based language you can use the HTTP to communicate with other applications.

The main advantage is the easiness to code it and use it, there are a lot of examples in the Web, particular in Adobe Manuals, how to communicate via HTTP protocol using Actionscript.

The main disadvantages are: you need a HTTP server and the communication is quite limited (PUT/GET methods and security issues) .

4)Use a client-server socket architecture. This method is composed by a C/C++ socket server and a Flash/Actionscript socket client (or vice-versa, but you will need Adobe AIR for making an Actionscript socket server).

The main advantages are: you do not need any additional technique to compile and run your code(C/C++ or AS3), it is easy to keep your applications updated, you can send all kind of data (in the end, it is all about bytes) and if you are coding an desktop application (Adobe AIR style) you have no problems using “localhost” .

The main disadvantages are: you have a client-server network architecture with all limitations that are involved in the process (delays, security and firewalls, etc…).

NOTE: I will make some code available soon.


Understanding Flash’s Coordinate Systems

March 26, 2010