Weird query string variable behaviour (ActionScript 2)

May 2nd, 2008 § Comments Off on Weird query string variable behaviour (ActionScript 2) § permalink

I just discovered some strange behaviour in the Flash player if you try to change variables passed in through the query string before the movie has finished loading.

That is:
If a movie is loaded with the URL:
movie.swf?a=initialValue

and the movie contains a script that does something like this:
_level0.a = "some other value"

the value of a will get reset to “initialValue” on every frame, until the movie finishes loading!

This is different than if you pass in the variable using flashVars. If you use flashVars, the variable stays set, as you would expect it to.

Here are some tests to demonstrate the behaviour. It’s best to clear your cache in between each test, or you will get varying results.

Here’s a screenshot from a test using query string variables:
screenshot from test movie
The test movie is embedded with code that passes the variable “a” set to “from html“. The movie continually displays the value of the variable “a” in the scrolling text field. On the fourth frame, it changes the the value of a to “set from script.”

At any time, you can click on the “Set” button to set the variable to “set from script.” When the movie is finished loading (there’s a 700K JPEG file on the last frame to make the movie large and slow-loading), you can click the “Stop” button to stop the scrolling text field from updating.

Play with both tests, and compare the effects if you clear the cache between tests or not, and try clicking “Set” at different times.

UPDATE: This only seems to occur in movies published for Flash Player 8! Here’s a test using a movie published for Player 7 and variables passed via the query string:

And, of course, I have no idea how ActionScript 3/Flash Player 9 behaves in a similar situation…

Where Am I?

You are currently browsing entries tagged with quirks at bunnyhero dev.