Flash CS3 Documentation |
|||
| Learning ActionScript 2.0 in Adobe Flash > Data and Data Types > About variables > About loading variables > Using FlashVars in an application | |||
Using FlashVars to pass variables into Flash is similar to passing variables along the URL in the HTML code. With FlashVars, instead of passing variables after the filename, variables are passed in a separate param tag as well as in the embed tag.
this.createTextField("myTxt", 100, 0, 0, 100, 20);
myTxt.autoSize = "left";
if (_level0.myURL == undefined) {
myTxt.text = "myURL is not defined";
} else {
myTxt.text = _level0.myURL;
}
|
NOTE |
|
By default, HTML code publishes to the same location as myflashvars.fla. |
<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="myURL=http://weblogs.adobe.com/"><param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <embed src="myflashvars.swf"FlashVars="myURL=http://weblogs.adobe.com/"quality="high" bgcolor="#ffffff" width="550" height="400" name="myflashvars" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /> </object>
This code passes a single variable called myURL, which contains the string http://weblogs.macromedia.com. When the SWF file loads, a property named myURL is created in the _level0 scope. One of the advantages of using FlashVars or passing variables along the URL is that the variables are immediately available in Flash when the SWF file loads. This means you don't have to write any functions to check if the variables have finished loading, which you would need to do if you loaded variables using LoadVars or XML.
The text http://weblogs.macromedia.com, a variable in the HTML file, appears in the SWF file.
|
NOTE |
|
All browsers will support string sizes as large as 64K (65,535 bytes) in length. FlashVars must be assigned in both the |
Flash CS3
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000668.html
Comments
animagics said on Jul 23, 2007 at 9:06 AM : da4seen said on Jul 23, 2007 at 6:53 PM : No screen name said on Aug 6, 2007 at 11:10 AM : No screen name said on Aug 7, 2007 at 3:25 PM : todddominey said on Aug 7, 2007 at 4:40 PM : AmarShah said on Sep 10, 2007 at 10:28 AM : kaos2 said on Sep 10, 2007 at 11:23 AM : go mama go said on Sep 21, 2007 at 11:35 AM : AndreLelis said on Nov 22, 2007 at 10:50 AM : TessandraFae said on Mar 4, 2008 at 7:55 AM : No screen name said on Jul 29, 2008 at 12:34 PM :