2
votes

I'm a newbby in Adobe AIR/Flex.

I have developed a simple Flex web app. that through 2 Php's, can connect to a DB and return an XML result of the query. I uploaded the PHP and Flex files to my internet server, and the app. works fine.

My question is:

How can I make the same app. work in Adobe AIR? In other words, I have made a new AIR project, and I copy/paste the Flex code. When I run the project, it does not work and say things like:

[RPC Fault faultString="Error #2070: Security sandbox violation: caller cannot access Stage owned by ." faultCode="Client.CouldNotDecode" faultDetail="null"] at mx.rpc.http::HTTPService/http://www.adobe.com/2006/flex/mx/internal::processResult()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:851] at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:188] at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43] at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74] at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()

So I think that in my AIR app. I cant write HTTP services. Or maybe I cant use the php file that connects to the DB, makes the query and then return an XML. How can I transform the Flex app. in an AIR app. Do I have to use the SQLConnect and that stuff? Cant I use my php's files that work well?

Thanks.

My regards.

Alan

1

1 Answers

0
votes

You can write AIR applications that connect to your PHP, I use coldfusion and java so not exactly sure what differences there will be but should be none on the server side.

The AIR application will require access, or compiled with, the services-config.xml and the three files it includes. For my AIR apps it seemed like the "includes" in the servies-config.xml file did not work and I had to copy the contents of those three files into the main file.

On the compile line you will require something like: -services "C:\Blazeds\tomcat\webapps\chat\WEB-INF\flex\services-config.xml" (sorry, I develop on a windows machine), but you will require the full path to your actual services-config.xml file. That line is in my Additional Compiler Arguments with my locale option.

This also requires you to create the project with a server side option.

You might want to also look at moving the code into a separate project, and then have both your AIR and web app use that third project with the code. Then one change in the code can affect both version, of course that means everything would have to be recompiled.

PS. I found the Adobe AIR Programming Unleashed to be a good book for this information.