Tutorials

ActionScript 3 and FlashVars

FlashVars?!?

FlashVars is synonymous to command line parameters. When a java program is run in this way:
java myJavaApp.class hello

myJavaApp can gain access to the command line parameter, “hello” from it’s args.
public static void main(String [] args) {
  System.out.println(args);
}

A flash program, however, is ran inside a browser. You will have to the pass the “hello” value inside the HTML where you add the SWF object.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="400" id="myflashvars" align="middle">
  <param name="allowScriptAccess" value="sameDomain" />
  <param name="movie" value="myflashvars.swf" />
  <param name=”FlashVars” value=”myCommandLine=hello”>
  <param name=”quality” value=”high” />
  <param name=”bgcolor” value=”#ffffff” />
  <embed src=”myflashvars.swf” FlashVars=”myCommandLine=hello” quality=”high” bgcolor=”#ffffff” width=”640″ height=”480″ name=”myflashvars” align=”middle” allowScriptAccess=”sameDomain” type=”application/x-shockwave-flash” pluginspage=”http://www.adobe.com/go/getflashplayer” />
</object>

Then you will access “hello” on ActionScript this way:
var flashVars:Object = root.loaderInfo.parameters;
trace(flashVars.myCommandLine);

When to use FlashVars?

You can use FlashVars to just about any Flash application that requires loading of additional configuration. YouTube, for example, uses FlashVars in their flash video player to determine the path of the FLV file it needs to load.

3 comments so far...

ActionScript 3 and FlashVars at Phlashers – Philippine Flash … | Flash Designers
May 13th, 2010

[...] Read the original here: ActionScript 3 and FlashVars at Phlashers – Philippine Flash … [...]

Flash ActionScript: Your Visual Blueprint for Creating Flash-enhanced Web Sites | Ebook Online Free
May 13th, 2010

[...] ActionScript 3 and FlashVars at Phlashers – Philippine Flash … [...]

Jumping Anaconda » Blog Archive » Link Time – Watch Snoop Dogg’s Hilarious “Oh Sookie” Music Video!
June 28th, 2010

[...] ActionScript 3 and FlashVars at Phlashers – Philippine Flash ActionScripters [...]

You must be logged in to post a comment.