
Working with a multitier application model
65
How you choose to access data in your Flex application impacts performance. Because a Flex
application is cached on the browser after the first request, data access is responsible for
significantly affecting performance while the application runs. Flex provides several solutions for
data delivery to the client. It delivers data through runtime services that invoke Java classes loaded
in the Flex classpath, or sends proxy requests to web services or HTTP servers.
Using the WebService component enables you to use a SOAP-based approach, but it does not
always yield the best performance. Also, there is extra overhead for the additional XML with the
SOAP encoding when compared to AMF. On average, AMF is three times faster than SOAP and,
with very large payloads, can be up to six times faster. This is because AMF uses a binary protocol
that greatly reduces the size of the payload compared to XML-based soap packets for the same
data.
The performance of SOAP with web services is also dependent on your web services
implementation. Different application servers use different web service back ends, so you might
see performance differences depending on the implementation. The only way to understand how
well your implementation will perform is to load-test your services.
Many times, the choice depends on your existing applications and how you choose to integrate
them with your back end server-side resources. The performance of web services depends greatly
on your application server’s underlying implementation of the web services engine, so you should
load-test to see how well it performs.
Controlling runtime code execution
Flex uses an event-driven application model, which is manifested in both user interaction with the
user interface and code execution based on system events. For more information about events, see
Chapter 16, “Working with ActionScript in Flex,” in
Developing Flex Applications
.
Using events to handle user interaction
User interface controls have event properties to which you can assign functions, called event
handlers, that respond to events. The following example shows a simple event handler that
displays text in a TextArea control when the user clicks a Button control:
<mx:Script>
<![CDATA[
function Hello() {
text1.text="Hello!";
}
]]>
</mx:Script>
<mx:Button label="Clear"
click="Hello();
" >
<mx:TextArea id="text1" width="150" text="This will be cleared" />
Summary of Contents for FLEX-GETTING STARTED WITH FLEX
Page 1: ...Getting Started with Flex...
Page 4: ...4 Contents...
Page 22: ...22 Chapter 1 Introducing Flex...