Couple of things jump out at me here:
1) I would switch to GET requests. POST requests tend to be... peculiar... sometimes. So in your PHP, change it to $_GET and in your MXML, just remove the method="POST" from the HTTPService.
2) Using proxies versus allowing access. This is a little trickier. I am not sure of your skill level, so I'll just give you my impressions of working with PHP. In general, I use proxies instead of using crossdomain.xml files to allow access. Remember that your development environment's sandbox will allow you to hit any PHP page anywhere to get data. Once deployed, though, you're either going to need a proxy page if you're ihitting a third-party domain or you're going to need a crossdomain.xml file on the target domain that allows access from your SWF.
3) Make sure you are deploying the SWF file, the wrapper, and the PHP file all on the same server that is running PHP, and that you are using a network request (ie, "http://...") to access the application.
4) If you're just running the SWF file as compiled from Flex Builder and requesting it as a file resource, then your relative request to the PHP file might not be pointed at the right location. I would adjust this to use a full URL so you are sure you are pointing to the right place.
English isn't my nation language so I understand 1% Your sentences. It must be POST - not GET - POST is safer and it can have more chars.
I think something is wrong here:
private function ShowResult(event:Event):void
l1.text = event; //here I have error: Event to an unrelated type String.
1 person found this helpful
Ah, ok. Try this:
l1.text = event.result;
thx - it works :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:HTTPService id="UserRequest" url="file.php" useProxy="false" method="POST" result="ShowResult(event)" showBusyCursor="true">
private function ShowResult(event:ResultEvent):void
l1.text = event.result.toString();
<mx:TextInput x="243" y="67" id="t1"/>
<mx:Button x="289" y="130" label="Button" id="b1" click="UserRequest.send()"/>
<mx:Label x="301" y="188" text="Label" id="l1"/>