MetaFilter is turning ten! Help us celebrate at one of dozens of meetups.



Passing Variables to Flash with URLs
December 4, 2006 4:58 PM   RSS feed for this thread Subscribe

How can I change variables in a Flash movie based a URL parameter?

I have some text in my Flash movie, and I want to change it based on a parameter in the URL. For example, if the URL ends with something like ?text=beer, I want the Flash movie to say "beer."
posted by kirkaracha to computers & internet (6 comments total) 1 user marked this as a favorite
Passing Variables to Flash from HTML via Query String
Google Query: pass variables to flash url
posted by niles at 5:11 PM on December 4, 2006


url variables appear in the _root scope. So if you should just be able to write

textfield.text = text;
posted by grumblebee at 6:20 PM on December 4, 2006


You probably just want to pass the query string to Flash using javascript, like this.

You can tack the variables onto the movie parameter as in the above example, or use another parameter called flashvars.

grumblebee, query string variables are only available to the _root of a movie if the swf is called directly. If it is in object and embed tags, as it usually will be, stuff from the url won't be available to it. Variables appended to the movie parameter would be, but they'd be static unless built using something like the javascript method above.
posted by thinman at 7:59 PM on December 4, 2006


Or you could use SWFObject. I have. It works well. Wish I'd remembered it before posting above.
posted by thinman at 8:03 PM on December 4, 2006 [1 favorite]


You're right, thinman. I misunderstood the original post. I thought he meant vars appended to the end of the swf url.
posted by grumblebee at 9:01 PM on December 4, 2006


Another recommendation for SWFObject, which makes detection, embedding and passing in variables nice and tidy.

For displaying the text, you need to put a Dynamic Text field into the movie, give it an Instance Name, and set it to embed any characters you might need to use (otherwise it won't know how much of your chosen font it'll need to retain). The variable you've passed in will exist in the root of the movie, so if your text field is also in the root you'll just need to use
instanceName.text = variableName;
posted by malevolent at 11:28 PM on December 4, 2006


« Older Within the last year, I read a...   |   So I left NYC in 2000, right a... Newer »
This thread is closed to new comments.


Related Questions
I'm building my first Flash program, and I need... May 30, 2009
Actionscript community site? March 20, 2008
Does anyone know of a book that covers Flash CS3... September 3, 2007
Actionscript development on OS X that doesn't suck? May 14, 2007
ActionScript book for an experienced programmer? March 30, 2007