PDA

View Full Version : Communication PHP - AS 3


Boris28
11-27-2008, 03:31 PM
Hello,

please help me with communication between flash CS3 (Actionscript 3) and PHP. .sfw and PHP script are on the same server. I need to send variables
from flash to php and get response from php back to flash in XML format. I need to know, if this code is good and right or if there is a better solution for solving this problem.


function CommunicationFlashPHP():void
{
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, dataLoaded);
var request:URLRequest = new URLRequest("http://PHPScript.php?what=question" + "&sid=" + _sid + "&actualLevel=" + _actualLevel);
loader.load(request);
}

function dataLoaded(evt:Event):void
{
var xmlResponse:XML = XML((evt.target as URLLoader).data);
trace(xmlResponse);
}

Boris28
11-27-2008, 08:36 PM
please, no one knows answer of my question?

Mithridatism
11-27-2008, 10:55 PM
It's kinda hard without seeing the php.. if you need general info about reading and sending to php, I found these two tutorials quite helpful: link1 (http://www.wuup.co.uk/as3-basics-sending-variables-from-as3-to-php/) link2 (http://www.flash-db.com/Tutorials/loadingAS3/loadingData.php?page=4).

To get your stuff in XML format, just let php output its data like <whatever>" . $row_whateverlist['whatever'] . "</whatever>.

Boris28
11-27-2008, 11:57 PM
thanks very much, really helpful links ;) I found there what I was looking for :)