September 26, 2007

Flashforward Boston: SWX

Rough draft of notes

Aral Balkan is talking about SWX.

Some post lunch jumping to capture a room of a full of people in the air yelling SWX.

Aral likes to consult, speak, and teach about user experience design, development processes, and software architecture. Works primarily with Flash, Flex, and a focus on open source. Founded osflash.org. Currently working on SWX.

What is SWX: new and native data format for Flash platform. Like JSON which is data in JavaScript. SWF is the native format for Flash. Want to put data in a SWF.

Terms:
SWX: Native format for Flash.
SWX RPC: RPC protocol encoded in SWX.
SWX PHP: PHP backend for SWX.
SWX Tools: Service Expolkire
SWX AS Lib: Optional, high-level AS library that handles SWX RPC calls.
SWX APIS: APIS for Flickr, Twitter
Public gateway: Open SWX RPC endpoint

Why SWX: Issue with existing data formats.
loadVars, loadVariables: deserializing string is complicated, it's plumbing, should be handled for you
XML: What data structure is being loaded, first child, last first, what child
Remoting: Created SWX because of remoting. Go to Adobe and search for remoting classes. Barrier of entry is too high. Doesn't work with Flash Lite.

SWX just works. SWX is easy. swxformat.org
Demo of Services Explorer: Test services installation of PHP SWX Services.

Launch Data Analyzer, Launch Flash, AS 2 FLA: Create MovieClip named loader, In actions panel:

loader.serviceClass = "Flickr";
loader.method = "swxPhotosGetRecent";
loader.debug = true;
loader.loadMovie("http://swxformat.org/php/swx.php", "GET");

Data Analyzer has data that was returned. Creating second MovieClip called image:

// hack to get things up and running, see if it works
function onEnterFrame()
{
    if (loader.result)
    {
        image.loadMovie(loader.result.photo[0].src);
        onEnterFrame = null;
    }
}

swxformat.org/faq/ for information about Flash IDE Sandbox warning issue

swxformat.org/download (SWX ActionScript library) comes with classes and examples.

import org.swxformat.SWX;

var swx:SWX = new SWX();
swx.gateway = "http://swxformat.org/php/swx.php";
swx.debug = true;
// got rid of loader MovieClip
var callParameters:Object =
{
    serviceClass: "Flickr",
    method : "swxPhotosGetRecent",
    result: [this, resultHandler]
}
swx.call(callParameters);
function resultHandler(event:Object)
{
    trace("Hello");
    var imageSrc:String = event.result.photo[0].src;
    image.loadMovie(imageSrc);
}

Currently this only works with AS2.

How to create your own service side class. SWX MAMP Bundle to work with PHP on a Mac allows working with things easily. One click run on Mac, just download ZIP for Windows or Linux if you have a running web server with PHP.

HighScores.php SWX services example

<?php
class HighScores
{
    function getNames()
    {
        return array('Branden', 'Mario', 'Chafic');
    }
}
?>

Changing example from above:

swx.gateway = "http://localhost:8888/phph/swx.php";
serviceClass: "HighScores",
method: "getNames",

// updated resultHandler

var names:Array = event.result;
for (var i=0; i < names.length; i++)
{
display.text += names[i];
}

TextField component called display

FlashLite 2.0 and 2.1 are supported.

Showing demo of miniflickr using CS3. Trying to demo it on his Nokia N95 (couldn't get network).

Showing application with SWX that pulls Twitter data.

SWX Ruby (Locomotive one click Mac installer for Ruby)
creating swxrpc ruby application. Line of code to install SWX Ruby.
Showing example using Ruby service, same loader calls.

SWX uses: Mashups for Flickr, Twitter, Jaiku, Numpa, Nabaztag, etc.
Flickr API: current, MIT license, upload, actively maintained

Mobile applications: Limitations no POST. DeviceCentral doesn't support LocalConnection.

Games, Kiosks, CDs, Wrap it with AIR (Twimpa is an example)

SWX has a showcase on swxformat.org

AS2, Flash 6+, Flash Lite 2.0, 2.1 Mobiles, Wii, PS3, PSP, Chumby

Soon: AS3/Flash 9

Roadmap: Writting RFCs for SWX and SWX RPC, bundles for other platforms, more APIs.

nabaztag.com

Tags: flash flashforward2007boston swx