Parlez-vous Français? Read the SWX documentation in French by Gilles Bertrand.

SWX documentation in Netherlands (Dutch) by Folkert Hielema: Nederlandstalige SWX Documentatie.

Definitions

Last modified on 2008-01-24 11:56:52 GMT. 0 comments. Top.

Here are some definitions of SWX-related concepts to start us off with a common vocabulary for talking about SWX.

  • SWX: Native data format for Flash. It is a subset of the SWF format. SWX SWFs are regular SWF files that are used to store just data.
  • SWX RPC: RPC protocol encoded in SWX. Allows you to call methods on server-side classes and get the results in SWX format.
  • SWX PHP: SWX RPC implementation in PHP. SWX PHP is currently the only implementation of SWX RPC but there will be Python, Ruby, J2EE, .Net, etc. implementations in the future.
  • SWX Tools: The SWX Service Explorer & SWX Data Analyzer. These tools come bundled with SWX PHP and will work with any future implementations of SWX RPC.
  • SWX AS: A high-level ActionScript library that handles 
the client-side queuing and execution of SWX RPC calls. You don't have to use the ActionScript library to work with SWX RPC as SWX is native to Flash but the library does provide you with useful functionality such as cross-domain access, queueing of data calls, etc.
  • SWX APIs: APIs for Flickr, Twitter, etc. I am as excited about the SWX APIs as I am about the SWX data format and SWX RPC as they provide Flash developers with a very easy way to create mashups. In fact, if you hit the Public SWX RPC gateway (see below) at swxformat.org, you can use these APIs with ActionScript alone (no server-side programming is necessary.)
  • Public SWX RPC gateway: Open SWX RPC endpoint. The Public SWX RPC Gateway
is at http://swxformat.org/php/swx.php. You can use the public SWX
APIs from this gateway in your own applications without having to
write any server-side code whatsoever.

Supported platforms and technologies

Last modified on 2007-08-25 08:47:13 GMT. 0 comments. Top.

Swx Supported Platforms

You can create and load SWX SWF files with any version of Flash (5+) as they are simply SWF files. As far as manually creating SWX files go, SWX is supported on Flash 5+.

SWX PHP, the current SWX RPC implementation that I'm working on, creates SWX files that are compatible with Flash 6+, Flash Lite 2.0 and Flash Lite 2.1. Currently, SWX PHP does not support Flash 9/AVM2 but it will eventually do so.

SWX AS, the SWX ActionScript library, compiles on Flash 7+ Flash 6+ and MTASC.

You can use SWX PHP currently to create applications that run on mobile phones (Flash Lite 2.0/2.1), the Nintenso Wii, Sony PS3, and devices like the Nokia N800 internet tablet and the Chumby.

You can also wrap SWX-based applications to create desktop versions using Adobe Air.

SWX (SWF Data Format)

Last modified on 2007-08-25 08:51:46 GMT. 0 comments. Top.

SWX is the native data format for Flash. Data is stored as SWF bytecode (you can't get more native than that on the Flash Platform) that is interpreted by the Flash Player. The SWX format is a subset of the SWF format (just like JSON is a subset of JavaScript).

SWX is open. I am in the process of writing an Internet Draft (I-D) for SWX which I hope will become an informational RFC.

You can loadMovie() SWX data files and they are ready to use the moment they are loaded. You don't need to deserialize or massage the data in any way before using it as it is stored in native Flash objects.

Why do we need a new data format?

Last modified on 2007-09-27 13:53:14 GMT. 9 comments. Top.

When I first announced SWX, Patrick Mineault, lead developer of AMFPHP, questioned whether SWX was reinventing the wheel. Why, he asked, do we need SWX when there is AMFPHP? (AMFPHP is a PHP implementation of a Flash Remoting gateway).

To start with, comparing SWX and AMFPHP is like comparing apples and oranges. As I stated earlier, SWX is a new data format for Flash and SWX RPC is a remote procedure call protocol encoded in SWX. As such, we can compare SWX to AMF (the data format) and SWX RCP to Flash Remoting (the RPC protocol) and SWX PHP (my PHP implementation of SWX RPC) to AMF PHP.

So the real question becomes, does the Flash Platform need a new data format and a new RPC protocol? I believe it does and here are some reasons why:

  • Existing formats are non-native, complicated, require parsing and/or writing plumbing code e.g., XML, variable-encoded strings (LoadVars, loadVariables), Flash Remoting, etc.
  • SWX files have low processor overhead when parsed by the Flash Player as they are native (SWF bytecode)
  • SWX RPC is the only RPC solution for Flash Lite 2.0 and 2.1 (and thus for mobile Flash applications). Flash Remoting does not work with Flash Lite.
  • Most important: SWX, being native, has inherent advantages such as cross-platform data exchange (via allowDomain support for SWF files), simplicity (no ActionScript library is necessary to use it, although there is a high-level library if you want to use it), etc.

It's my first belief that every platform can benefit from a native data format that does not require parsing. The main advantage of SWX over other data formats and of SWX RPC over other RPC solutions is ease of use. I hope that this ease of use will spur a wealth of development of data-driven applications and mashups on the Flash Platform by developers who may traditionally have shied away from creating such applications because it was just too darn hard to do so.

SWX RPC

Last modified on 2007-08-25 10:51:47 GMT. 7 comments. Top.

SWX RPC is a remote procedure call protocol encoded in SWX format. You use it to call methods on server-side classes (called services in SWX RPC) and get the results returned to you in SWX format.

SWX RPC is open. I am in the process of writing an Internet Draft (I-D) for SWX RPC which I hope will become an informational RFC.

SWX RCP is stateless, lightweight, and uses HTTP as the transfer protocol.

A typical SWX RPC call involves parameters sent from Flash to the SWX RPC endpoint (gateway) in JSON format. These consist of serviceClass, method, and args parameters that define the method on the service class that you want to call on the back-end and the arguments that you want to send to that method. The resulting data is returned to Flash in the result property.

SWX PHP adheres to SWX’s core philosophy of Systemwide Simplicity.

The SWX Philosophy

Last modified on 2007-08-25 14:21:23 GMT. 0 comments. Top.

SWX is designed to provide Flash developers with a simple and enjoyable experience when building data-driven applications in Flash. The key words here are simple, enjoyable and experience.

Simple: SWX is as simple as possible but no simpler. If something can be made simpler without sacrificing essential core functionality, I’ll make it simpler.

Enjoyable: Because life should be fun. The SWX tools aim to put a smile on your face, do the heavy lifting, provide a seamless experience and be aesthetically pleasing so you’ll be inspired todo the same in your applications.

Experience: These core tenets apply to the whole experience of SWX, not just the API or codebase. That includes the web site, documentation and tools. The focus is to make it as easy as possible for you to get up and running with SWX from the moment you first visit the SWX web site. I call this Systemwide Simplicity.

Systemwide simplicity

Last modified on 2007-08-25 10:52:45 GMT. 0 comments. Top.

A system is only as simple as its most complicated part. It's not enough to just simplify individual components and processes, you must also simplify the relationships and interactions between components and sub-processes. Systemwide Simplicity takes a wider approach to simplicity that involves understanding and supporting the entire user experience.

It is thus my aim to make it as easy as humanly possible for Flash developers to start creating data-driven Flash applications from the moment they arrive on the SWX homepage to the moment they first get data into Flash using SWX RPC.

How simple is SWX? Moo card example.

Last modified on 2007-08-25 11:47:17 GMT. 3 comments. Top.

Swx Flickr Tutorial Moo Card

SWX is so simple that instructions for getting data into Flash using it easily fit on to a Moo card (ask me for one if you see me around!)

To get a list of the most recent 100 photos from Flickr into Flash, do the following:

  • Open up the SWX Data Analyzer
  • In Flash, create a new FLA and create a movie clip on the Stage. Give it the instance name loader.
  • Write the following code on to the frame that the loader movie clip is on:
loader.serviceClass = "Flickr";
loader.method = "swxPhotosGetRecent";
loader.debug = true;
 
loader.loadMovie("http://swxformat.org/php/swx.php", "GET");

That’s it! Test your movie and look in the SWX Data Analyzer to see the results being loaded in to Flash from Flickr. That’s how simple SWX is.

If you want to display the results from within Flash, create a long, single-line dynamic text field on stage and give it the instance name status. Add the following code to the timeline:

function onEnterFrame()
{
    status.text = loader.result.photo[0].src;
}

Initially, the status text field will display undefined until the data is loaded and then it will display the URL of the first photo from the list of recent photos that is loaded from Flickr. Notice how you can access the results as native Flash objects the moment they’re loaded. No deserialization or massaging of the data is necessary!

In this example, you used the SWX Public Gateway (http://swxformat.org/php/swx.php) which you're welcome to use in your own applications to create mashups with the supported APIs (Flickr, Twitter, etc.) without having to host or write any back-end code yourself.

The Public SWX Gateway

Last modified on 2007-09-11 20:32:55 GMT. 3 comments. Top.

There is a public gateway that you can use on swxformat.org to call the various SWX APIs without hosting your own PHP installation of SWX.

Take a look at the Start Page for the SWX public gateway. This is the same Start Page that you will see when you install SWX PHP or the SWX PHP MAMP Bundle (only it's called start.php instead of index.php here on swxformat.org).

The URL for the public gateway is:

http://swxformat.org/php/swx.php/

You are encouraged to make use of the SWX public gateway but please do not flood it with so many requests that it resembles a denial of service attack!

The public gateway also hosts versions of the SWX Service Explorer and SWX Data Analyzer.

SWX Service Explorer

Last modified on 2007-08-25 14:24:15 GMT. 0 comments. Top.

You can use the SWX Service Explorer to explore server-side services on your development machine.

Use the SWX Service Explorer on the SWX Public Gateway to explore the publicly-available SWX APIs on swxformat.org. You can call these APIs directly from Flash without writing any server-side code or hosting your own SWX RPC gateway.

Debugging with the SWX Data Analyzer

Last modified on 2007-08-25 14:28:21 GMT. 0 comments. Top.

You can see the data that is returned from an SWX call using the SWX Data Analyzer if you turn debug mode on.

To turn debug mode on, set a property called debug in your data holder movie clip. For example:

dataHolder.debug = true;

If you're using the SWX ActionScript Library, set the debug property on your SWX class instance to true.

var swx:SWX = new SWX();
swx.debug = true;

Once you’ve set debug mode on, start the SWX Data Analyzer and test your Flash project. You will see the returned data appear in the SWX Analyzer.

Make sure you start the SWX Data Analyzer before you run any SWF files that use it. Also make sure that there is only one instance of the SWX Data Analyzer running at any one time.

SWX Analyzer is a Flex application. An Adobe AIR (desktop) version is now also available for OS X and Windows.

SWX PHP

Last modified on 2007-08-25 14:30:17 GMT. 1 comment. Top.

SWX PHP is an open source SWX RPC implementation in PHP. You can download and install it to develop your own SWX service classes and deploy it to your own server to host your own SWX gateway.

SWX PHP has its own section in the documentation. To find out more about it, read the SWX PHP documentation, watch the screencasts, and download SWX PHP.

How do you pronounce SWX?

Last modified on 2007-08-25 11:49:12 GMT. 0 comments. Top.

It's pronounced "swix".

Who’s the cute little guy, then?

Last modified on 2007-09-14 06:59:28 GMT. 0 comments. Top.

If you’re asking about the SWX mascot/logo, his name’s Datum. He lives in a SWF shell.

Download the Adobe Illustrator file for Datum. You can also print your own SWX Moo cards and SWX Stickers that feature Datum.

SWX Credits and Acknowledgments

Last modified on 2007-10-07 12:12:26 GMT. 0 comments. Top.

Conceived, developed, and maintained by Aral Balkan.

Hosted on OSFlash; the home of the Open Source Flash community.

  • Folkert Hielema: For creating Swadge and Swoot, and for your support, invaluable help and collaboration. It's cool to feel that I'm not working on SWX alone! :)
  • Larry Mahony: Thanks to your bug report, SWX runs well on PHP 4.4.3 too now! :)
  • Wouter Verweirder: For contributing the non-cURL fallback routine for the SWX Twitter API. Thanks to your code, developers without cURL can use the SWX Twitter API too!
  • Steve Webster: Refactoring the service class, TheTenWordReview API.

To everyone whom I’ve learned from, thank you!

Igor Kogan and Wang Zhen for Flasm and Matthias Kramm for Swfdump (part of Swftools). My life would have been astronomically more difficult without these two excellent SWF disassemblers.

Douglas Crockford for thinking different and giving us JSON.

Tony Million for making 0xED, a hex editor for OS X that was extremely useful for viewing SWF bytecode.

Patrick Mineault for creating AMFPHP. I hope SWX and AMFPHP become bosom buddies!

Apple, for making my amazing MacBook Pro and for giving me OS X. After 22 years of increasing amounts of frustration with DOS and Windows, I love using a computer again. My Mac has definitely made me a better developer!

Twitter for keeping my connected and the cafe at my local Borders, where a portion of SWX was written, for giving me a change of scene in the mornings.

The lovely folks at MAMP for making it child’s play to get a development server up and running on OS X and the gang at ApacheFriends for doing the same for Windows and Linux users. SWX will include custom distributions of both of these packages that also contain SWX.

Macromates for making Textmate. It’s my best friend :)

SimpleTest, AsUnit, and SVN for giving me piece of mind.

My friends at Adobe for making Flash, Flex and Apollo possible.

Our wonderful OSFlash community sharing your knowledge openly and for giving me inspiration and hope every day. You guys rock!

Brighton, my fellow Brightonians, and our lovely little geek community here in the UK for your inspiration and friendship.

A special thank-you to Niqui, Pete, Dave, Paul, Justin, Danny, Jeremy, John and Serge, for your feedback, support and encouragement.

And last, but definitely not least, a big thank-you to my parents for your lifelong support and for always encouraging me regardless of what I’m doing. There’s a bit of you in everything I do.

SWX Licensing & Legalese

Last modified on 2007-08-25 11:34:35 GMT. 0 comments. Top.

SWX, swxformat.org, Datum (the SWX logo) are trademarks of Aral Balkan.

SWX, the SWX web site and any other related products are offered as-is without any warranties or guarantees of any kind as per the Terms and Conditions.

SWX is not affiliated with Adobe. Adobe and Flash are registered trademarks of Adobe, Inc. All other trademarks and copyrights belong to their respective owners.

SWX has several different components, each of which is licensed separately. Specifically, there is the (A) the SWX Server, (B) sample code, examples (both server-side and client-side) and the ActionScript API, and (C) documentation.

The spirit of licensing these components separately is to make sure that the correct license is chosen for each component to allow users as much freedom as possible in making use of SWX.

A. SWX Server

License: Creative Commons GNU GPL.

The SWX Server includes the SWX gateway, SWF assembler and all other server-side components that are integral to the functioning of SWX.

The rationale here is that if you change or improve the SWX Server and distribute the results, you should make your source and improvements available under the same license so that everyone benefits.

The GNU GPL license is basically the same license that Amfphp uses so you can use the SWX Server anywhere you are able to use Amfphp.

B. Sample code, examples, and the ActionScript API

License: MIT.

Sample code and examples (on both the client-side and server-side) and the SWX ActionScript API are released under the more liberal MIT license. This applies to all samples and examples that come with the various SWX download packages and to those on aralbalkan.com and swxformat.org.

This means that you can modify and use the code for the samples and examples (PHP, Flash, ActionScript, etc.) in your personal or commercial projects regardless of whether they are open-source or close-source. This includes the ActionScript API for SWX (the PHON serializer, etc.) So, to make it crystal clear, if you make a Flash or Flex application that is based on the Flash and ActionScript code in SWX, you can pretty much do whatever you like with it (except remove the copyright notice in the code or hold me liable for damages, etc.)

C. SWX documentation and blog post content

License: Creative Commons Attribution-Share-Alike 2.0 UK: England & Wales Licence.

Basically, you are free to do what you like with the SWX Documentation and blog post content as long as you give proper credit and share your modifications under the same license.

16 Responses to “Documentation”


  1. 1 R. Rajesh Jeba Anbiah Oct 8th, 2007 at 2:48 pm

    For sometime, I’m lurking here and at AMF-PHP. I’m quite interested to know why the current RPC code for ActionScripters aren’t like:
    bar = foo.method(1, 2, “foo”)

    Would it be possible with this way? (Your callback version seems to be quite complex for ActionScripters–I’m not AS guy BTW).

  2. 2 aral Oct 8th, 2007 at 3:59 pm

    Hi Rajesh,

    It’s because the calls are asynchronous. In other words, they don’t return immediately. (They make a call to the server and it takes a while for them to return). That’s why we need a callback/responder.

  3. 3 R. Rajesh Jeba Anbiah Oct 9th, 2007 at 10:07 am

    Aral,

    Don’t get offended; I believe you can improve.

    But, I’m quite disappointed with this way; this doesn’t look like “RPC”

    I’m just trying to understand (I’m no ActionScripter): can’t we add a wrapper API, so that real RPC can be achieved? Say, the asynchronous callback is internally handed in that wrapper; the default callback has to wait with a provision to change the callback to users’ callback:
    service = InitService(gateway_url, “Service”) //with default callback
    service = InitService(gateway_url, “Service”, function(){}) //with user callback as in JavaScript?

    Isn’t possible at all? (’coz I’m asked to work on the server-end, if that’s possible, I can inform)

    Is this datatype http://www.amfphp.org/docs/datatypes.html reference also true for SWX?

    Thanks.

  4. 4 R. Rajesh Jeba Anbiah Oct 11th, 2007 at 8:33 am

    Aral,

    It’s me again. After googling, I came across this discussion http://www.actionscript.org/forums/showthread.php3?t=37562

    Do you think, if similar approach can be utilized for SWX-RPC?

    Thanks

  5. 5 aral Oct 11th, 2007 at 9:45 am

    Hi Rajesh,

    You could, if you wanted to, apply the architectural discussions in that thread to an application that uses SWX. The SWX ActionScript Library, however, will not be implementing such an interface as it is not a structural MVC framework (you can build one on top of it, if you like, or use one like Arp or Cairngorm with it).

  6. 6 jan Nov 9th, 2007 at 5:59 pm

    Hi Aral!
    I really like the idea of SWX and I have just started to try it out.
    But I was wondering, what is the minimum installation / what are the least needed files if I want to use ONLY own services on my deployment server? (if I don’t want a service browser and other debugging helpers)

    Thank you and regards,
    Jan

  7. 7 Jon Andrews Nov 21st, 2007 at 11:39 am

    Hey Aral,

    Firstly, fantastic effort and great project. Many thnaks for sharing it with us all.

    I’ve got a quick question for you - I’ve been using Fluorine here and there and what I like about it from a coders point of you is that by using the Object.registerClass method and matching up a server side class with an identical one on the flash side, I can get code completion within my Eclipse build environment.

    For example, to do the following you are relying on knowing the properties of your result object and spelling them correctly:

    loader.result.photo[0].src

    Rather than having to know I’m getting a result object back that contains an array of photos, each with a src property - If I use Flourine with registerClass I can know what I’m getting back using code completion.

    Is this possible with SWX?

    Kind Regards,

    Jon

  8. 8 Sascha Nov 23rd, 2007 at 10:35 am

    Hello Aral,

    thanks for everything!

    Could you please let us know, how to send a specific argument to the FlickAPI?
    I am trying to apply the ‘photosSearch’ method to the above Moo card example, however do I have difficulties in sending the parameters (as a feedback I receive a message = “Parameterless searches have been disabled. Please use flickr.photos.getRecent instead.”):

    loader.serviceClass = “Flickr”;
    loader.method = “photosSearch”;
    var myArr:Array = new Array();
    myArr[”tags”]=”jamaica”;
    loader.args=myArr;
    loader.debug = true;
    loader.loadMovie(”http://swxformat.org/php/swx.php”, “GET”);

    Even though I tried various ways to apply the parameters to the search I am always getting the same result.
    I saw you having applied the method within the SWX Service Explorer, so I kindly ask you for some guidance on how to…

    Thank you very much :-)

    Sascha

  9. 9 aral Nov 23rd, 2007 at 2:37 pm

    Hi Sascha,

    The tags parameter is the third one and it accepts a comma-delimited list of tags. So, in your example, you would use:

    loader.args = [null, null, “jamaica”];

  10. 10 myvideostv Nov 24th, 2007 at 12:32 am

    Im working on it with my site.i try to import ads over rss or xml feeds. dont work :-( idea why ?

  11. 11 Rob Mar 22nd, 2008 at 7:43 pm

    Hi. When trying to pass arguments with Flash to twitter, the data analyser reports “Missing argument for 1 in replies()”

    Here’s what’s running:

    loader.serviceClass = “Twitter”;
    loader.method = “replies”;
    loader.args = [”username”, “password”];
    loader.debug = true;
    loader.loadMovie(”http://swxformat.org/php/swx.php”, “GET”);

    Any clues as to what’s wrong?

    Rob

  12. 12 Raheal Mar 25th, 2008 at 12:25 pm

    Hello Aral,
    I have been trying to use SWX api with flash lite 3.0, however, hav’nt succeed in doing so. I am aware of flash lite 3.0 new security features, hence i am hosting the swx service on my own web server along with placing the crossdomain.xml file in the server’s root folder. On the mobile device, i am using the loadpolicy() function to load the crossdomain file. Despite of that data access is not possible. Once again the client is a mobile device. Can you advice on how to make it work with flash lite 3.0. a quick response will be very much appreciated

    Thanks

  13. 13 Nolan Apr 9th, 2008 at 10:03 pm

    I just posted a workaround for using SWX with AS3 here:
    http://flexgraphix.com/blog/?p=34

  1. 1 SWX: A new data exchange format for Flash. at Aral Balkan Pingback on Mar 29th, 2007 at 6:11 pm
  2. 2 SWX Twitter API for Flash and Flash Lite at Aral Balkan Pingback on May 7th, 2007 at 4:26 pm
  3. 3 Scott Janousek » Blog Archive » Flash Lite and SWX seminar going on right now Pingback on Jul 20th, 2007 at 7:44 pm

Leave a Reply





Bad Behavior has blocked 4687 access attempts in the last 7 days.