Skip to main content
Known Participant
January 20, 2010
Answered

Passing parameters from HTML to Flash Object

  • January 20, 2010
  • 1 reply
  • 2186 views

I know this should be very simple, but in following the examples I can find on passing parameters from HTML to my Flash App I have not been successful. I would like to find a relatively current example using AS3, Flash CS4.

If it helps, I need to pass the url of an XML file off to the flash app so that it can go pick up instructions on what it is supposed to be playing. We want to do it this way because we don't control the web site so we can't just leave the XML file on the server and maintain it as needed.

I don't know if I'm just making typo's or what. Code snippets of both sides of this would be greatly appreciated.

Thank you for any help.

This topic has been closed for replies.
Correct answer jscamposcr

hey i think that i know what you need to do, try this "<param name="FlashVars" value="xmlURL=yourValue">" in the HTML and then create a var in Flash like this:

var xmlURL:String = this.loaderInfo.parameters.xmlURL;

luck!!!, tell me if it works

1 reply

Ned Murphy
Legend
January 20, 2010

Code snippets can indeed be helpful.  Can you show what you have already tried that is not working.

Known Participant
January 20, 2010

Well, honestly, I'd hoped to not have to embarrass myself by posting obviously flawed code instead of reading a tutorial or something. But if you think it will help, here goes:

vpcFlashVars.flashVarsLoaded=false;

vpcFlashVars.loaderComplete=loaderComplete;

vpcFlashVars.useFlashVars=useFlashVars;

this.loaderInfo.addEventListener(Event.COMPLETE, vpcFlashVars.loaderComplete);

function loaderComplete(e:Event)
{
   this.flashVars=this.loaderInfo.parameters;
   this.flashVarsLoaded=true;

   this.useFlashVars();       
}

function useFlashVars()
{
textBoxTest.text = vpcFlashVars;
if(vpcFlashVars.locationURL)
{
dbgText = vpcFlashVars.locationURL + "VideoPlayerDefault.xml";
}
else
{
dbgText = "VideoPlayerDefault.xml";
}

}

and here is what DW has, I modified the original because something I read said I couldn't just pass // and . so I put in %2f etc.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="400"
  FlashVars="locationURL=http://adobefool.com/snowpeak/" id="FlashID" title="movie test">
    <param name="movie" value="mvc/VideoPlayerController.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="opaque" />
    <param name="swfversion" value="6.0.65.0" />
    <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
    <param name="expressinstall" value="Scripts/expressInstall.swf" />
    <param name="FlashVars" value="locationURL=http%3a%2f%2fadobefool%2ecom%2f%2fsnowpeak%2f" />
    <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="mvc/VideoPlayerController.swf"
    FlashVars="locationURL=http%3a%2f%2fadobefool%2ecom%2fsnowpeak%2f" width="550" height="400">
      <!--<![endif]-->
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="swfversion" value="6.0.65.0" />
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <param name="FlashVars" value="locationURL=http%3a%2f%2fadobefool.com%2fsnowpeak%2f" />

I hope I got what you needed. As you can see all I am  doing with it so far is trying to display the data in a text field to see what I got. I do actually pass off the URL to a player object but I'm still at the "I wonder how this works" stage and not doing things with it.

Message was edited by: Chris_Rehm put in the DW text.

jscamposcr
jscamposcrCorrect answer
Participant
January 20, 2010

hey i think that i know what you need to do, try this "<param name="FlashVars" value="xmlURL=yourValue">" in the HTML and then create a var in Flash like this:

var xmlURL:String = this.loaderInfo.parameters.xmlURL;

luck!!!, tell me if it works