Search Flex Samples

Using HTTPService tag to send/receive variables to a server-side script

The following example demonstrates a very simple usage of sending parameters from Flex to a server-side script (written in ColdFusion) and then displaying the server response in our Flex application. The server-side script is a simple echo/”Hello world” type script, but it accepts URL or FORM variables, so you can send using the GET or POST HTTP-method.





<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

layout="vertical"

creationComplete="httpService.send(myObj);">



<!-- Parameters to send to remote script. -->

<mx:Object id="myObj" name="john" />



<mx:HTTPService id="httpService"

url="http://www.flash-mx.com/mm/greeting.cfm"

method="POST"

resultFormat="flashvars" />

<mx:Label text="{httpService.lastResult.welcomeMessage}" />

</mx:Application>



0 comments:

Related Flex Samples

Learn Flex: Flex Samples | Flex Video Tutorials Flex Examples