Call Chris at (615) 521-1890 for a free quote.
615.521.1890
Nashville Interactive - Home

Blog

Passing FlashVar Strings to Flash with AS3

Jun 1 2010

I found all sorts of complicated posts on the in-ter-net about this but none were clear and concise. Hopefully this will be… (but I’m no Flash expert) I basically needed to pass an xml file path to a Flash image rotator through the embed/object markup in the html file. Using FlashVars this is actually pretty easy in AS3. note: I usually use swfobject to work with Flash but this particular project called for the more “traditional” embed/object tags.

The html markup…

&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; width=&quot;640&quot; height=&quot;348&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;&lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot; /&gt;&lt;param name=&quot;FlashVars&quot; value=&quot;xml_path=xml/news2.xml&quot; /&gt;&lt;param name=&quot;src&quot; value=&quot;preview.swf&quot; /&gt;&lt;param name=&quot;flashvars&quot; value=&quot;xml_path=xml/news2.xml&quot; /&gt;&lt;embed type=&quot;application/x-shockwave-flash&quot; width=&quot;640&quot; height=&quot;348&quot; src=&quot;preview.swf&quot; flashvars=&quot;xml_path=xml/news2.xml&quot; wmode=&quot;transparent&quot; quality=&quot;high&quot;&gt;&lt;/embed&gt;&lt;/object&gt;<!--formatted-->

The ActionScript code…

root.loaderInfo.parameters.xml_path;

(or if you need it in a variable…)

var xmlFilePath:String = root.loaderInfo.parameters.xml_path;

Hope that helps someone.