SWX: SWF Data Format

Icon

SWX is the native data format for Adobe Flash. This blog is about all things SWX, SWX RPC, SWX PHP and the SWX APIs (Flickr, Twitter, etc.)

Release 0.1h

SWX Alpha 0.1h is now available for download.

0.1g was broken -- please download this release.

What's new in Alpha 0.1h:

  • Alpha 0.1g had old versions of the SwfCompiler and SWX gateway. This release fixes that. It should now function as per the docs.

Release 0.1g

SWX Alpha 0.1g is now available for download.

There are major API changes in this release. Please make sure that you read the release notes below.

What's new in Alpha 0.1g:

  • API Change. The className property is now "serviceClass".
  • API Change. The data property is now "arguments".
  • How service methods are called has changed. See detailed description and code sample, below.
  • Deployment: Removed some .svn folders that were somehow checked in.
  • SVN: Added tags to repository.
  • Deployment: Renamed text folder to "docs" to make it clearer.
  • Docs: Updated docs to reflect API changes in 0.1g

Starting with 0.1g, you are no longer limited to sending a single argument to your server-side service class method. Previously, you would set the data property on your data holder movie clip and this would be sent as the first (and only) argument to your server-side method. This meant that existing service classes (for example, ones you had already written for Amfphp or classes in third-party public APIs) would have to be re-written. Of course, we don't want that. We want to be able to use existing service classes without changing them and that means that we need to be able to pass any number of arguments. Starting with 0.1g, you can.

The data property has now been replaced with the arguments property to reflect this change.

Set the arguments property on your data holder movie clip to the array of arguments that you want to pass to your server-side method.

For example, if the method signature for your service method is getDirectMessages($user, $pass), your arguments array would look something like:

dataHolder.arguments = ['aral', 'mypass'];

In this example, SWX will call getDirectMessages('aral', 'mypass') on the server.

Here is how the echoData sample looks now.

Flash:

import org.swxformat.*;
 
var myData:Array = ['data', 'to', 'send'];
 
dataHolder.serviceClass = "Simple";
dataHolder.method = "echoData";
dataHolder.arguments = [myData];
 
Prepare.forPhp(dataHolder);
 
dataHolder.loadMovie("http://a.com/path/to/swx.php", "POST");

PHP:

class Simple
{
	public function echoData($data)
	{
		return $data;
	}
}
 

The introductory SWX post has an extended version of the above example, including comments.

SWX Alpha 0.1f release

Please upgrade to version SWX Alpha 0.1f as the 0.1e release was missing a crucial PHP file. Thanks!

SWX Alpha 0.1e release

SWX Alpha 0.1e is now available for download. Please upgrade to 0.1f (SWX Alpha 0.1f is now available for download) as the 0.1e build was broken.

What's new in Alpha 0.1e:

  • Added manual PHON serializer.
  • Modified echo sample application to use the manual PHON serializer.
  • Renamed the automatic serializer AutoPhpSerializer. It's still there but you can choose whether you want to use it. I may remove this in future iterations.
  • Modified the SWX gateway to handle null values. The auto serializer was sending them over as undefined.

This release introduces a slightly modified workflow for working with SWX. I don't believe that it is more complicated though (and may even be clearer.) I really liked how clever the auto serializer was but, as others have noted, and as I had mentioned previously myself, overriding the toString() method of core classes like Object, Array and String can lead to side-effects in some instances. I was using this as an easy stop-gap workflow but it appears that people got stuck on this point and couldn't see beyond it so I've introduced the manual serializer.

The main additional complexity is that now you have to manually prepare the data for the back-end using Prepare.forPhp(). You must do this every time the data changes, before using loadMovie().

Get SWX Alpha 0.1e from the download page.

SWX Alpha 0.1d release

SWX Alpha 0.1d is now available for download.

What's new in Alpha 0.1d:

  • Fixed bug with the SWX gateway that threw script errors for incorrectly formed requests. This bug was introduced with the addition of GET functionality in 0.1b.

What's new in Alpha 0.1c:

  • The example FLA is now saved in a format that can be read by Flash 8 (oops, sorry + thanks Paddy for alerting me to this!)

What's new in Alpha 0.1b:

  • PHP 4 and PHP 5 support. Tested with PHP 4.4.2 and PHP 5.1.4
  • Added GET support to the gateway. You can now call the gateway with both POST and GET

Get SWX Alpha 0.1d from the download page.

About SWX

SWX is the native data format for the Flash Platform.

SWX on Twitter