Accessibility

TechNote (Archived)

Attempts to send data from a Flash movie to a server are not working

Issue


Using the Load Variables or Get URL action to pass data from a Flash movie in a browser to the server is not working. The server-side application does not record the variable information. This only happens when using the Flash Player 4.0r20 (Macintosh) and 4.0r25 (Windows).

Reason


This version of the Flash Player is inserting an extra ampersand character when passing variables from a Flash movie. This will affect users who are sending data to a server-side mechanism, such as ASP or CGI.

The extra ampersand is inserted as the first character in passed variables. It can affect movies using the GET or POST method. Because of this additional character, it may prevent the destination file from receiving the data if it is not written to expect the extra ampersand.

This was a problem with 4.0r20 and r25 versions of the Flash Player. It was fixed in the 4.0r26 version and later. The newest players can be downloaded from the Flash Player Download Center.

Example:

  • This is a normal URL followed by a query string:

    http://www.domain.com/page.asp?name=john
  • This is a URL with a query string, and an extra ampersand:

    http://www.domain.com/page.asp?&name=john

Solution


There are several design and scripting workarounds to this problem.

The solutions listed below will work regardless of which version of the Flash 4 Player the user has installed.

  • The receiving script could be written to expect the extra character as part of the name of the first variable received. Therefore, a "dummy" variable could be created in the Flash movie whose name would be prefixed by the extra ampersand when passed. When Flash sends data from the movie to the server, it sends the name/value pairs in the order they were created. Theoretically, this would be the first variable declared in the movie, in the first frame action. Since this variable - which is not needed in the movie or script - is the only one affected, the other variables and values should be accessible for server-side processing.

    This may be the easiest solution for this problem, as it requires minor changes to most movies. However, this should be experimented with, due to the complexity of some Flash projects and some server-side scripts.
  • The advantage to using Send Using GET with the Get URL action is that all of the variable information from the current timeline will be collected for output automatically and passed on the query string. However, if only a few values are to be passed, and the author knows which variables they are, it's easy to simply pass them on the end of the URL using an expression.
    1. Add the action Get URL, and set the URL field to "Expression".
    2. In quotes, add the URL name, followed by a question mark and the name of the first variable to pass. Add an equal sign to the end of this.
    3. Add the closing quotes, followed by an ampersand. Add the variable name to pass first to the end.
    4. To add more variables to the above, add another ampersand, an open quote, another ampersand, and the name of the next variable followed by an equals sign. Add closing quotes, another ampersand, and the name of this next variable. Repeat this step for each desired value to pass.
    5. Change the "Window:" setting if desired. However, leave the "Variables:" setting to "Don't Send". This is important - the variables have already been passed with the above expression. Click OK to finish.
  • The extra character is only passed from Flash when the Load Variables or Get URL action is sending data from the main timeline. Putting all variables or "submit" buttons with these actions into a movie clip will pass the data as normal, without the extra character. Flash considers variables to exist only as such in the timeline it is in. A movie clip, in this case, is being used as a "container" for the variables, unaffected by this particular problem.
  • If an author wants to detect which release version of the Flash Player the client is using, it is now possible to do using a Flash scripting scheme.

    The Flash Player inserts a hidden value into the Flash movie's main timeline called $version, which contains a string that indicates which release version of the player the user has. To access this value, use the eval function. The resulting string will contain three letters indicating the user's platform, and a series of numbers indicating exact player version.

    Example:

    MAC 4,0,20,0
    WIN 4,0,25,0

    Using the function substring, the information can be parsed and a logical statement created to decide what to do, depending on this condition.

    Example:

    Set Variable: "player" = Eval("$version")
    If (substring (player,9,2) eq "20" or substring (player,9,2) eq "25")
    Set Variable: "user" = "They have the r20 or r25 player."
    Else
    Set Variable: "user" = "They do not have this player."
    End If

    Note: The $version variable was added after the original release of the Flash 4 Player. If the user has an older release of the player that does not contain the $version variable, this string will be empty.


AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:tn_14234
Browser:Chrome
Internet Explorer
Netscape
Opera
Safari
Firefox
Database:DB2
Informix
MySQL
Oracle
SQL Server
Sybase
MS Access

Products Affected:

flashplayer