Code Snippets   | [Bill's Home]

Reading XML from Flash (Pt. 5)

We can also pass parameters into the Flash movie with:

window.document.myFlash.SetVariable("debug", sendText);

where myFlash is the name and ID of the Flash movie, and debug is one of the variables within it. For example, enter you name here, and it should update the text in the movie (enter your name and then click away from the box, or press TAB after you've entered your name):

Enter your name:

Here's the code that is added to allow Javascript to communicate with the Flash movie:

<form name="form1" onSubmit="doPassVar(sendText);" action="#">

<p>Enter your name:
<input type="text" name="sendText" maxlength="45" onChange="doPassVar(this);">

<input type="submit" name="Submit" value="Add Name">
</form>

<script language="JAVASCRIPT">
function doPassVar(args){
var sendText = args.value;
window.document.myFlash.SetVariable("debug", sendText);
}