MACROMEDIA FLEX-GETTING STARTED WITH FLEX User Manual Page 85

  • Download
  • Add to my manuals
  • Print
  • Page
    / 148
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 84
POSTing to the Server with Flex
In this example, I’ll post a simple subscription form to the
server. The Flex code for the interface appears in Example 5-1.
Example 5-1. Form.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:HTTPService id="srv" url="http://localhost/formtest.php"
method="POST"
result="mx.controls.Alert.show
(srv.lastResult.toString());">
<mx:request>
<first>{first.text}</first>
<last>{last.text}</last>
<email>{email.text}</email>
</mx:request>
</mx:HTTPService>
<mx:Form>
<mx:FormItem label="First Name">
<mx:TextInput id="first"/>
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput id="last"/>
</mx:FormItem>
<mx:FormItem label="Email">
<mx:TextInput id="email"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Subscribe" click="srv.send()"/>
</mx:FormItem>
</mx:Form>
</mx:Application>
This is pretty straightforward stuff. At the bottom of the ap-
plication file is a big form tag that has all of the fields and the
Subscribe button. At the top of the file is the definition for the
HTTP service that will be called when the user clicks the Sub-
scribe button.
The server code, shown in Example 5-2, is equally straightfor-
ward.
POSTing to the Server with Flex | 69
Page view 84
1 2 ... 80 81 82 83 84 85 86 87 88 89 90 ... 147 148

Comments to this Manuals

No comments