PDA

View Full Version : How do you retrieve POST variables from HTTP


kaizenx
02-11-2009, 11:11 AM
I have a Flex application sitting in a browser.

How do I retrieve the POST variables being posted to the page?

Thanks.

Peter Cowling
02-11-2009, 02:47 PM
Hi,

Well you can use things like AMFPHP, but the most straightforward way to get started is illustrated here (http://www.adobe.com/devnet/flex/articles/php_getstarted.html).

Propelsolutions
02-11-2009, 09:18 PM
Assuming you're using PHP, the easiest way to do this is to pass the variables with SWFObject.

Then, you just echo out the php post values into the embed statement. In Flex, you just use Application.application.parameters to get at the variable. For example, in this example to access the value of MY_VARIABLE you'd just use Application.application.parameters.MY_VARIABLE:



<script type="text/javascript">
// <![CDATA[

var flashvars = {};
flashvars.MY_VARIABLE = "<?php echo $_POST ['myvar']; ?>";
flashvars.MY_VARIABLE2 = "<?php echo $_POST ['myvar2']; ?>";

var params = {};
params.menu = "false";
params.allowScriptAccess = "sameDomain";

swfobject.embedSWF("myflexapp.swf", "myflexapp", "500", "500", "9", "/js/expressInstall.swf", flashvars, params);

// ]]>
</script>