Passing Variables to Flash with URLs
December 4, 2006 4:58 PM 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."
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."
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
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
grumblebee, query string variables are only available to the _root of a movie if the swf is called directly. If it is in
posted by thinman at 7:59 PM on December 4, 2006
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
Best answer: 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]
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
posted by grumblebee at 9:01 PM on December 4, 2006
Best answer: 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
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
This thread is closed to new comments.
Google Query: pass variables to flash url
posted by niles at 5:11 PM on December 4, 2006