Alcides Fonseca

40.197958, -8.408312

AAAX

AAAX is an alternative to AJAX inside Flash. It was developed by myself and the guys when working on PalcoDesktop, a desktop Adobe Air in Flash. Inside the Prototype.as we included AAAX (code below). This allowed to just ask for remote content by:

new AAAX { trace(content); // will output the HTML/XML/Whatever returned.
});

And we used it mainly with the Flash XML Parser, but also worked with JSON.

Here’s the magical code:

// AAAX

import flash.net.*;

URLRequestDefaults.userAgent = “AAAX Rocks :)”;

var AAAX = function(url:String, callback:Function) { var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest(url); var header:URLRequestHeader = new URLRequestHeader(“pragma”, “no-cache”); request.requestHeaders.push(header);

this.load = function(event:Event) : void { var loader:URLLoader = URLLoader(event.target); callback.apply(event.target,[loader.data]); } this.load.callback = callback; loader.addEventListener(Event.COMPLETE, this.load); try { loader.load(request); } catch (error:Error) { trace(“Unable to load requested document.”); } };