The Blog

Oct 24, 2007

More on Flex Frameworks 

by Maxim Porges @ 11:25 PM | Link | Feedback (0)

Droop-Nizzle has posted some well-organized thoughts on web frameworks in general, and the need (or lack thereof) for a framework in Flex.

I mostly agree with his summary. It would be nice to have better test support in Flex (although I like mostly FlexUnit from what I have seen so far), and common app structure is always a good thing.

However, the Ajax.request example is a bit of a moot point. Ajax is just an object somebody put in a JavaScript library, and ActionScript's prototypes are just like JavaScript's, so doing the same style of syntax in ActionScript is a trivial matter. Class and usage sample below.

new RemoteCall("untitled.txt",
function():void {
mx.controls.Alert.show("Yeah It Worked: " + arguments[0].result);
},
function():void {
mx.controls.Alert.show("boo I didn't work: " + arguments[0].fault.faultString);
}
);


package remoting
{
import mx.rpc.http.HTTPService;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;

public class RemoteCall
{
private var _service:HTTPService;

public function RemoteCall(url:String, result:Function, fault:Function)
{
_service = new HTTPService();
_service.url = url;
_service.addEventListener(ResultEvent.RESULT, result);
_service.addEventListener(FaultEvent.FAULT, fault);
_service.send();
}
}
}