Skip to main content
March 26, 2008
Question

Set Variables from HTML

  • March 26, 2008
  • 2 replies
  • 483 views
Here is the set up, I have a video player embedded in an html file. The player will play a lead in video for branding purposes IF the user has not viewed this lead in video yet. ELSE it wil play the video they specified and then continue to play the rest of the videos in a que.

Everything is fine except, the current video is dependant on the HTML page the view is at and I would rather just have 1 swf file rather than 1 swf file for every video.

So my question is, how can i get the HTML page to tell the swf file which file to load after the lead in file. I essentially need to send this parameter from the HTML file to the swf file - How do I do that??

Thanks!
This topic has been closed for replies.

2 replies

Damon Edwards
Inspiring
March 26, 2008
Using FlashVars is just appending the variable to the SWF's url. So, in your embed script, where ever you have the path to your SWF, like, mymovie.swf, you just append whatever variable you need to that. So, lets say you want to pass in a name, you would use

mymovie.swf?name=dzedward

Then, in flash retrieve it like so:

root.loaderInfo.parameters.name;

Lets say you want to pass in first and last name:

mymovie.swf?firstName=Damon&lastName=Edwards

retrieve it like so:

root.loaderInfo.parameters.firstName;
root.loaderInfo.parameters.lastName;

Now, if you're using SWFObject to embed your SWF, its as simple as:

so.addVariable("name", "dzedward");

retrieving it the same way as above.
March 26, 2008
so to send i use

mymovie.swf?myMove=movie.flv

and in flash

myVariable = mymovie.swf?name=myMovie ?

is myVariable defined as an empty or null variable a head of time?
Where do I stick the flashvars code in the HTML?
Damon Edwards
Inspiring
March 26, 2008
If you use
mymovie.swf?myMove=movie.flv
then in flash use:
myVariable = root.loaderInfo.parameters.myMove;

"Where do I stick the flashvars code in the HTML?"

Everywhere you have the location of your SWF set. If you're using Flash to publish your html file, it will spit out a lot of AC_RunActiveContent crap. So, you'll need to root through it to find yourmovie.swf and add the vars to it.

Damon Edwards
Inspiring
March 26, 2008
Send the parameter in via FlashVars. Get the vars out using root.loaderInfo.parameters.varName
March 26, 2008
quote:

Originally posted by: dzedward
Send the parameter in via FlashVars. Get the vars out using root.loaderInfo.parameters.varName


Not familiar with the flashvars. can you point to an example / documentation?