About variables 103
Remember, you need to make the same changes to both the object tag and the embed tag
to maintain consistency between all browsers. You might notice that the words are
separated by + punctuators. The words are separated this way because the values are URL-
encoded and the + punctuator represents a single blank space.
Because the ampersand (
&) serves as a delimiter for different name/value pairs, if the values
you are passing contain ampersands, unexpected results might occur. Given the nature of
name/value pairs and parsing, if you had the following values being passed to Flash:
my.swf?name=Ben+&+Jerry&flavor=Half+Baked
Flash would build the following variables (and values) into the root scope:
'name': 'Ben ' (note space at end of value)
' Jerry': '' (note space at beginning of variable name and an empty
value)
'flavor': 'Half Baked'
To avoid this, you need to escape the ampersand (&) character in the name/value pair with
its URL-encoded equivalent (
%26).
8. Open the urlvariables.html document, and find the following code:
?myURL=http://weblogs.macromedia.com&myTitle=Macromedia+News+Aggregator
Replace it with the following code:
?myURL=Ben+%26+Jerry&flavor=Half+Baked
9.
Save the revised HTML, and test your Flash document again.
You see that Flash created the following name/value pairs.
'name': 'Ben & Jerry'
'flavor': 'Half Baked'
NOTE
For a list of common URL-encoded special characters, see the Flash TechNote,
URL Encoding: Reading special characters from a text file.
NOTE
All browsers will support string sizes as large as 64K (65535 bytes) in length.
FlashVars must be assigned in both the object and embed tags in order to work on
all browsers.