Using flashvars with swfobject 2.2 and as3

After looking around in google almost 1 hour I did not find a simple example about using flashvars, as3 and swfobject 2.2 so I create this simple one.

Create the file index.html

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="www.argenisleon.com">

<title>Using FlashVars with SWFObject 2.2 in ActionScript3</title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
    <div id="flashitem"></div>
	<script type="text/javascript">
		var flashvars = {
			name1: "hello",
			name2: "world",
			name3: "foobar"
		};
		var params = {};
		var attributes = {};
		swfobject.embedSWF("flashvars-as3.swf",  "flashitem", "300", "300", "9.0.0","expressInstall.swf", flashvars, params, attributes);
	</script>
</body>
</html>

And a flash file named flashvars-as3.fla

    var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
    output.appendText("\n" + String(allFlashVars['name1'])+ "\n");
    output.appendText("\n" + String(allFlashVars['name2'])+ "\n");
    output.appendText("\n" + String(allFlashVars['name3'])+ "\n");

of course you need swfobject.js
This example will pass the variables name1, name2 and name3 from the html file to the flash player.

Also you can download the whole files here. flashvars.zip

One Response to “Using flashvars with swfobject 2.2 and as3”

  1. ISAAC says:


    MedicamentSpot.com. Canadian Health&Care.Special Internet Prices.Best quality drugs.No prescription online pharmacy. High quality drugs. Order drugs online

    Buy:Synthroid.Lumigan.Accutane.Actos.Petcam (Metacam) Oral Suspension.Zyban.Nexium.Retin-A.100% Pure Okinawan Coral Calcium.Mega Hoodia.Arimidex.Valtrex.Prednisolone.Prevacid.Human Growth Hormone.Zovirax….

Leave a Reply

You must be logged in to post a comment.