Learning ActionScript 2.0 in Adobe Flash |
|
|
|
| Working with Text and Strings > About loading text and variables into text fields > Using FlashVars to load and display text | |||
Using FlashVars is simple, but requires you to publish your SWF files along with HTML documents. You modify the generated HTML code and include the FlashVars properties in both the object and embed tags. You can then test the Flash document by viewing the modified HTML document in your web browser.
To use FlashVars to pass variables from HTML to your Flash document:
this.createTextField("my_txt", 10, 10, 10, 100, 21);
my_txt.text = _level0.username;
|
NOTE |
An HTML document publishes, by default, to the same directory as your FLA file. If an HTML document does not publish, select File > Publish Settings and then select the Formats tab. Make sure that you select HTML. |
object tag to match the following.
The code you need to add is in boldface.
<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="flashvars" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="flashvars.swf" /><param name="FlashVars" value="username=Thomas" /><param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <embed src="flashvars.swf"FlashVars="username=Thomas"quality="high" bgcolor="#ffffff" width="550" height="400" name="flashvars" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /> </object>
The SWF file displays the name "Thomas" in the dynamically created text field on the Stage.
For information on security, see Understanding Security.
|
|
|
|