There are three main ways to send data to a Flash movie:
FlashRemoting
LoadVariables
Appending to Object Tag querystring
The latter two methods are old-school techniques, and they have their advantages/disadvantages. LoadMovie and FlashRemoting allow you to load fresh data from the server, but they also require an event-handler. This event-handler is asynchronous (not immediate, not tied to timeline) so that your movie will know what to do at a later point in time when the data has finished loading.
If you want your data to load immediately, you'd use the querystring technique to append a URLEncoded querystring to the PARAM and EMBED tags in the Flash webpage's HTML code. This technique works well if you want to insert data *immediately* into a Flash movie before it plays. However, it pollutes the _root scope with variables, which deviates from good OOP programming style. The biggest problem, however, is caching... if you want a Flash movie to receive new data every time the user visits the site, then the appended querystring will force the user to download a new copy of the SWF.
Here's an example of what you'd see in your browser cache if each Flash webpage contained a different querystring in the OBJECT tag:
beta.swf?myvalue=1
beta.swf?myvalue=2
beta.swf?myvalue=3
beta.swf?myvalue=4
These are actual files you'd find in your TemporaryInternetFiles folder of your browser. If each swf took up 100kb, then your users would have downloaded 400kb for the sake of putting a unique value into a single variable. Doh!
With Flash 6, users can download a SWF movie once, and still be able to receive new URLEncoded information at the time of loading. Instead of appending the querystring of URLEncoded name/value pairs to the OBJECT Tag, however, you can use the Flash 6 tag called "FlashVars". Simply create a new param tag with the name "FlashVars", and set the value with the querystring. End result: same querystring, different location, users can now cache the swf.
For non-Microsoft browsers, simply create an attribute called "FlashVars" in your EMBED tag, and insert the querystring as its value.
Complete instructions can be found on the Macromedia technote# 16417 at http://www.macromedia.com/support/flash/ts/documents/flashvars.htm
Posted by samuel at August 21, 2002 09:38 PM