Cabron Connector Logo
Another Open-Source Implementation of PHP - Flash Remoting
The Flash remoting allows to easily transfer complex data between ActionScript code running in a flash movie, and PHP code running on a webserver, in both directions.
In other words, it lets you to call (from ActionScript) PHP functions defined in files on a webserver as if they were defined in your ActionScript code.

Hello World!
You will need two files for this: a PHP file, helloService.php, and a flash movie.
The helloService.php should be placed in the services directory (which is located at the same level as the gateway folder). Contents of the php source file:
  function helloMethod($param1){
    return "Hello ".$param1;
The ActionScript code:
// include the classes - in the first frame
#include ""
#include ""

// create connector instance - once in a movie = new CabronConnector();
// set the location of the gateway

// define responder method
function helloMethod_Result(res){
  trace("Response:" + res);
// define error handler method
function helloMethod_Status(errMsg, errCode, shortErrMsg){
  trace("Error occured:" + errMsg);

// create service object - every time you need a function/method from a different php file
var helloService = cc.getService("helloService",this);
// call the method of the service

How does it work
The Cabron Connector does not use the AMF to transfer the data, it uses the LoadVars ActionScript object. So the data is transmitted as a regular POST, after it is serialzied in the CDE (Compact Data Exchange) format.
CDE is a proprietary text-based format, which tries to minimize the size of the data needed for representing a given structure, and it facilitates timed deserialization.

This can be useful when transferring huge amount of data from the PHP services to Flash. Because the LoadVars works in the main thread of Flash, the deserialization happens in the main thread, blocking the Flash movie. This can lead to:
  • The blocking of the main movie: the graphical elements won't animate for a while, and the interface does not respond to user events - this is the better case
  • The "A script in this movie is causing Flash Player to run slowly..." message can appear. This is the worse case.
To avoid these nasty situations, you can set the deserialization to be performed not on a single frame, but in a sequence of frames. This way the flash movie won't block, but of course there will be a difference between the frame when the data is loaded to Flash, and the frame when the data is deserialized and the Result handler is called.

Sources of inspiration / Other implementations

Please read the on-line documentation, it's accessible from the top menu.
In this distribution only syntax highlight is available for ActionScript code, no Reference Panel entries are defined.

The Cabron Connector consists of three different packages:
  • ActionScript classes
  • PHP classes
  • Printr Debugger classes and Flash Panel
The first two are necessary to get the connector working. The third one - the debugger - it's optional, but probably will save you a lot of time if you use it.

The MXP package will install the base ActionScrip classes, and the whole Printr Debugger.

The PHP classes will need manual install, which means that you need to copy the contents of the zip file in a directory under your DocumentRoot. It's suggested to put it to /cabronconnector/gateway.

After you copied the contents of the archive, you should generate the texmaps. This can be made by accessing the http://localhost/cabronconnector/gateway/utils/ page, and running the Forced Textmap Crator and then the Character Map converter utilities.

The Cabron Connector uses LoadVars.sendAndLoad() to transmit the data between Flash and PHP. So it should work in every browser in which these feature works. It was testd with:
  • IE6
  • Netscape 7.1
  • Opera 7.0
  • Mozilla 1.2.1
  • Netscape 4.7
    The PHP part will work with PHP 4.0.5 and above. If you don't use the object oriented approach in the services, it will work with PHP4.0.4 too.
  • (a href="">eatti)