
Now when I export the release build, using the same mecha-
nism as before, I get a slideshow.swf file that is 98 KB. That’s
far less than half the size of the original! To enable the client to
use this I need to copy the .swz file for the framework into the
same directory as the .swf file that references it.
Chat Widget
Reading stuff from the Web and displaying it is one thing. It’s
another thing to read and write data to a remote web server
from a widget that is placed on any page. To show how to do
this, I will create a very simple chat widget.
The first thing you have to understand is that for security rea-
sons, a Flash movie on your machine cannot make an arbitrary
request of just any URL. The Flash Player will first check for a
crossdomain.xml file on the target host. The crossdomain.xml
file (shown in Example 8-2) is telling Flash that “it’s OK if you
make a request of me.”
Example 8-2. Crossdomain.xml
<?xml version="1.0"?>
<!-- http://www.adobe.com/crossdomain.xml -->
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" />
</cross-domain-policy>
On the server side, I’m going to use a combination of MySQL
and PHP. The PHP code for the server is located in the code
download associated with this book on the O’Reilly website.
The Flex code for the user interface appears in Example 8-3.
Example 8-3. Chat.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
horizontalAlign="left" creationComplete="requestMessages();">
<mx:Script>
114 | Chapter 8: Flex for Widgets
Komentáře k této Příručce