O'Reilly logo

Getting Started with Flex 3 by Emily Kim, Jack D. Herrington

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Working with the Server

Most Flex applications are going to work with a web server in some shape or form. Thankfully, Flex makes this very easy to do by providing a rich set of web service tools. In this chapter, I’ll present two methods of accessing the server from a Flex application, and the server code that is required to support them.

You can access the server in a Flex application in five different ways:

POST or GET

You can use a Flex application just as you would an HTML form. Flex can bundle up the elements in a form and post them to your web server application just as the browser would. Your application won’t even know the difference.

Using HTTP services directly

In a manner similar to Ajax, you can make an HTTP request of the server, even supplying POST content, and receive the response asynchronously. That response can be whatever flavor of data you want: text, XML, YAML, JSON, whatever you like. For JSON data the as3corelib library (http://code.google.com/p/as3corelib/) provides an excellent JSON interpreter.

SOAP

Flex can access SOAP services directly using a set of Flex classes designed specifically for that purpose.

Remote objects

Flex applications can also make use of Flash’s remoting capabilities by using remote objects. To make this happen the server code needs to support AMF requests. This is a proprietary binary format. Thankfully, there are libraries in each of the major languages to support AMF.

Directly through sockets

When all else fails you can use TCP/IP ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required