O'Reilly logo

Actionscript Cookbook by Joey Lott

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

Using LoadVars and XML

The third way you can modify the scheduler application is to use server-side scripts that read and write to a file. The ColdFusion versions of these scripts are provided here in this example, but if you need to use another technology, it is not too difficult. You need two scripts: one to write data and one to read the data. The write script should take two parameters submitted via HTTP POST: the name of the file to which to write and the data to be written. Here is the ColdFusion example that you should name LoadVarsSharedObjectSave.cfm:

<cffile action="write" 
   file="#GetDirectoryFromPath(GetBaseTemplatePath(  ))##FORM.name#.so" 
   output="#FORM.data#" nameconflict="overwrite">

The other script should read the data from the file and return it to Flash. This script should accept a single parameter submitted via HTTP GET: the name of the file from which to read. Here is the ColdFusion example. You should name this file LoadVarsSharedObjectRead.cfm.

<cfsetting enablecfoutputonly="yes">
<cffile action="read" 
     file="#GetDirectoryFromPath(GetBaseTemplatePath(  ))##URL.name#.so" 
     variable="data">
<cfoutput>#data#</cfoutput>

Finally, you should make a few changes to the client-side ActionScript code in the Schedule component. The relevant snippet of code from that component is shown here with changes in bold:

#initclip

// The serializeObject(  ) and deserializeObject(  ) functions are the exact same code
// as the serializeObject(  ) and deserializeObject(  ) methods of the 

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