Friday, April 20, 2007

RIA and Flash

Last Wednesday I went to a seminar on the application of Flash technologies to produce Rich Internet Applications. Adobe has certainly been busy for the past year, as we are far away from the "banners and intros" main purpose for Flash. Two main names pop-up for discussion: Flex 2 and Apollo. Flex addresses the issue of producing web applications with Flash and ECMA Script (the ActionScript variant), in the same manner one would develop a HTML+Javascript solution. The coding language is named MXML, and allows to mingle the UI and the client-side scripting. The main advantages are the Flash remote communication capabilities (either via web services, flash remoting, and other RPC alternatives) and the Flash multimedia embedding. It's quite easy to add a video playing in a given canvas! As far as coding artifacts are concerned, all we need is at least an .MXML file, like the following:
<?xml version="1.0" encoding="utf-8"?>

<mx:ApolloApplication xmlns:mx="" layout="vertical" cornerRadius="12" alpha="0.7" borderStyle="none">
            import mx.collections.ArrayCollection;
            [Bindable] public var people:ArrayCollection = new ArrayCollection(["one", "two"]);
            private function doAddClick(_name:String):void{

    <mx:TextInput name="firstname" text="Type your name here"/>
    <mx:Button label="Add it!" click="doAddClick({firstname})"/>
    <mx:ComboBox dataProvider="{people}"></mx:ComboBox>
Yes, this is purely XML. One can add up pure actionscript files, wich, by the way, has some advantages over javascript (it's an OO language, for instance). The main drawback (yes, there is one) is the IDE is not free (unlike the compiler and SDK - those are FOSS! Also, there's no DTD, or XSD available to use in XML development editors, so we will probably have to stick to an Eclipse plugin (paid Flex Builder) until an open source alternative comes around. RIA has been forever tied to the sandbox concept: like all web applications, one can only access files that have been uploaded by the user in the present session. Another restraint is that a browser is needed to run the application. Here comes Adobe's Apollo. Take a Flex application, pass a short application XML descriptor, and with a couple of command line instructions you have a compiled and packed installer to a standalone windows/mac executable with the MXML contents. But they didn't stop there. Adobe also wants to catch up current HTML/JavaScript/AJAX developers, so Apollo also makes identical standalone applications out of pure HTML+JavaScript sites. But that's not all. to our coding pleasure, Apollo lets us access all Apollo's ActionScript facilities from Javascript, and vice-versa! This means one can code a javascript handler to access debug tracing, common dialogs, client-side file system, loke in the following example (taken from Mike Chamber's blog):
//called when button is pressed to select a file
function onFileClick()
 //this will trace out the string to the command line
 //get a reference to the desktop
 var f = apollo.flash.filesystem.File.desktopDirectory;
 //listen for the select event
 f.addEventListener(, onFileSelect);
 //open the browse dialog

Again, the SDK is (yet in alpha state) FOSS, but the IDE consists in an extension to Flex Builder, and thus is paid. But the technology itself seems quite promising. See Adobe Digital Editions for a quite nice real-world example. In short, I'm impressed with Adobe Labs, and it seems there's more to come in the next couple of months!