Flex 3/AIR version of CFLib demo
Yesterday I released an AIR application that lets you browser CFLib.org from your desktop. This application didn't take terribly long - except for some issues I ran into with the new security model.
Today I thought I'd try it with Flex. I'm a bit rusty with Flex but I figured it couldn't be too hard. Turns out I was right. With some help from Scott Stroz and Simeon Bateman, I was able to crank out the application in a lunch break.
The only part that confused me was - how do I use RemoteObject to talk to a CFC on another server, which AIR allows? Turns out you just need to get a copy of CF's services-config.xml file. I placed it in my Flex app and added this to my compile args:
-services libs/services-config.xml
Next, I edited the file to change
<endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
to
<endpoint uri="http://www.cflib.org:80/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
That's it. I guess it really isn't much of an AIR app. It doesn't detect online/offline. But I find it cool that it took me 1/5th the time and came out ten times prettier. I've included the AIR app as a download. I renamed it to cflib.zip as I'm too lazy to mess with IIS settings. Rename it and run. If you ran the demo from yesterday, the installer will complain that an application with the same name exists. Either uninstall the other one or supply a custom install location.
Also - I used Flex Builder's Include Source option so you can see my ugly MXML code. Awesome.
Comments
Cheers.
Just rename to .air. :)
Error: Cannot assign operations into an RPC Service (endpost)
I went to try it on my side and realized my eclipse/AIR setup is all messed up. I try to execute a compiled AIR app out of my eclipse and i get an error about it requires a version of AIR that is no longer supported.
I think i just need to upgrade to the latest beta AIR.
Im pretty sure it was the endpoint, but, it is case sensitive. If i remember right i camel cased it (Flex2Gateway) and beat my head against the proverbial wall trying to figure out what was wrong. You would think if my IIS is not case sensitive on the URL that the endpoint would not be also.
Also why name it flex2gateway? Im sure flex 2 is not going to be the last version. :)
Or is it meant to be Flex-Too-Gateway not version 2?
I think the way you mention is completely fine. The only thing I usually end up doing is handling most of it via actionscript instead of in the MXML, but that's all down to personal preference. If you're going to be using an MVC approach, I think it would make things easier to put it in actionscript in order to separate the view from the other components, but for a quick app, I think it works nicely :) I'm still reading up on all the blogs and articles for best practices, but I think that's still a work-in-progress :D
"This application requires a version of Adobe AIR which is no longer supported. Please contact the application author for an updated version."
"The application could not be installed because the AIR file is damaged. Try obtaining a new AIR file from the application author."


I dont pretend to know Flex/AIR yet, so im curious if Flex/AIR has changed or was it the way i setup my RemoteObject tag? I used a attribute called endpoint and i noticed you did not in your code.
<mx:RemoteObject id="roGetJob" destination="ColdFusion" source="test" endpoint="http://demo.dev/flex2gateway/"
result="onGetJobResult(event)" fault="onGetJobFault(event)">
<mx:method name="getJob">
<mx:arguments>
<jobNum>{jobNum.text}</jobNum>
</mx:arguments>
</mx:method>
</mx:RemoteObject>
Is there a best practice on defining the endpoint?