Category Archives: Mobile

Invoking RESTful and AMF services from Flex using WCF / MVC / FluorineFX in .NET

Rich Internet ApplicationsI’ve written a small Rich Internet Application using Flex and [dot]NET. Data from [dot]NET is returned to Flex using different technologies being MVC, WCF and FluorineFX.

In dot[NET], there are two MVC controllers, RestJsonController and RestXmlController. They both have about the same logic, but one returns Json, the other XML. There’s also a UserService with methods made public using both WCF and FluorineFX. For WCF, REST is used with both GET (WebGet) and POST(WebInvoke).

On the Flex side, REST calls are being done using URLLoader and URLRequest.  There are examples using GET and examples using POST. You’ll also see that URLVariables, Json strings or XML are used to transport data. For the AMF calls, a RemoteObject is used to call a FluorineFx gateway.

Flex only supports the HTTP Verbs GET and POST, so full REST isn’t really possible.

I created the example in Visual Studio 2010 (ASP.NET MVC 3 Web Application) and Flash Builder 4.5 Premium (SDK Version 4.5.1). You can easily open the .NET solution. The Flex source is configured to call localhost on port 53259, so make sure the .NET WebApp is started on that port (or change the Flex source code). For the Flex project, import it using ‘Existing Projects into Workspace’. Since Flash Builder has a problem with relative paths (adobe, please have a look at that), you’ll have to change some things. In the properties of the project, go to Flex Build Path, and set the Output folder to [root example project]/FlexDotNetREST/Flex, being the Flex folder under the root of the .NET Web App. Then right click FlexRest.mxml –> Run As –> Run Configurations… URL or path to launch should be http://localhost:53259/Flex/FlexRest.html.

A zip of the example can be downloaded here.

As I wife recently gave birth to a second daughter, I haven’t got the time anymore to blog a lot. So, explaining this will be difficult. But you have the source and I’ve written a lot of comment in the source it self. So check it out and let me know if it was useful.

Be sure to go and read some articles and blog posts on REST, especially the difference between low REST and high REST (lo-REST – hi-REST). A lot of developers/managers/companies think they have a RESTful api, but actually, they don’t.

http://blog.jonnay.net/archives/665-Hi-Rest-and-Lo-Rest,-two-broken-halves-of-the-tower-of-Babylon.html
http://lesscode.org/2006/03/19/high-low-rest/

WCF REST
REST in Windows Communication Foundation (WCF)
A Developer’s Introduction to Windows Communication Foundation 4

Continue reading

Flex Icon

Packaging a Flex Mobile Project using Ant for Android, BlackBerry or iOs

Flex IconIf you want to package a Flex Mobile Project using Ant, you’ll first need to compile your project to get a swf. ADT is the tool need to package your application. First of all, if you want lots of information, I recommend installing the Adobe Community Help.

Remember you can also do this by creating a Release Build (right click project –> Export… –> Flash Builder –> Release Build) of your Flex Mobile Project.

Continue reading

Flex Icon

Compiling a Mobile Flex Project using Ant and launching the swf using the Air Debug Launcher

Flex IconFirst of all, compiling a Mobile Flex Project is not the same as packaging one. Compiling is creating an swf, packaging is creating a ipa or apk file (Android or iOs). I’ll deal with packaging in a later post. If you double click on a compiled Mobile Flex Project swf, you wont see a thing. If you want to see your swf in action, you’ll have to use the Air Debug Launcher, ADL. Off course, instead of using Ant, you can also use the command prompt or Flash Builder.

Continue reading