今天看到了一个更好的方式: 用%26替换掉“&”。
相关地址:
http://www.permadi.com/tutorial/flashVars/
Both tags serve the same purpose, to specify a Flash movie. However, most Netscape browsers only understand EMBED tags, while Internet Explorer only understand OBJECT tags. Whenever you specify a Flash movie, you should use both. So, when using FlashVars, there are also two slightly different syntax, one for the OBJECT tag, and the other one for EMBED tag.
For the OBJECT tag, the syntax is as follows: <PARAM NAME FlashVars VALUE=[variable1=value1&variable2=value2&variable3=value3...]>
The param tag must be nested within the OBJECT tag.
For the EMBED tag, it is as follows: <EMBED .... FlashVars=[variable1=value1&variable2=value2&variable3=value3...] ...>
Each variable variable and value pair is separated by a '=' sign. A '&' sign separates the each pair.
So for example, if I have two variables, userName and score, the tags would look like this: <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="
http://macromedia.com/cabs/swflash.cab#version=6,0,0,0"
ID=flaMovie WIDTH=250 HEIGHT=250>
<PARAM NAME=movie VALUE="flaMovie.swf">
<PARAM NAME=FlashVars VALUE="userName=permadi&score=80">
<PARAM NAME=quality VALUE=medium>
<PARAM NAME=bgcolor VALUE=#99CC33>
<EMBED src="flaMovie.swf"
FlashVars="userName=permadi&score=80"
bgcolor=#99CC33 WIDTH=250 HEIGHT=250
TYPE="application/x-shockwave-flash">
</EMBED>
</OBJECT>
Several things that should be noted about variable names:
Use only letters, underline, and numbers. There should be no reason why symbols such as '$' or '#' must be used as variable names.
Do not start a name with a number (for example: 1message is an invalid variable name because it starts with a number; whereas message1 is a valid variable name).
Flash will certainly reject or get confused if you use a variable name that starts with a number or other special characters - except underlines (ie: _message, and _1message are valid names).
A variable name should not contain any <space> character (ie: my message is an invalid name, my_message is a valid name).
And for variable values, there are also rules:
Characters needs to be URL encoded (see: Introduction to URL Encoding). This means that special characters, such as =, &, <SPACE>, + need to be substituted with their URL encoded form. For example: name=John Doe. Here, the <space> between John and Doe needs to be encoded with + sign, so you need to pass it as name=John+Doe or name=John%20Doe. (Flash doesn't seem to enforce this, but you should follow the proper way.) Search for URL encoding on the net for more details on this subject.
If you need to include an & as part of a value, such as in ingredients=Beef&Pork, then you need to encode the & like this: ingredients=Beef%26Pork. The %26 is an encoded form of the & sign. The number 26 is the hexadecimal code of the character &. If you need to know the encoding value of a particular character, consult an ASCII table. There are other characters that need to be encoded, such as <, >, /, ?.