# Passing a variable to flash

**URL:** <https://forum.kirupa.com/t/passing-a-variable-to-flash/276818>\
**Category:** flash\
**Created:** [December 3, 2008, 10:44pm UTC](https://forum.kirupa.com/t/passing-a-variable-to-flash/276818 "2008-12-03T22:44:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![windstorm](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@windstorm](https://forum.kirupa.com/u/windstorm)\
**Post date:** [December 3, 2008, 10:44pm UTC](https://forum.kirupa.com/t/passing-a-variable-to-flash/276818/1 "2008-12-03T22:44:27Z")

</div>

Hi,

I’m pretty new to AS3 and although I keep seeing the same solution all over the forums, I can’t seem to get my flash movie to work properly.

I’m trying to pass a parameter id from a URL to my movie…for example:  
[[COLOR=#336699]http://www.mysite.com/xmas\_2111.swf?id=3[/COLOR]](http://www.mysite.com/xmas_2111.swf?id=3)

Here is the AS code:

```auto
 
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

var idString:String = root.loaderInfo.parameters.id;

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest
   ("xmas.xml"));

function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseNames(xmlData);
}

function ParseNames(nameInput:XML):void {

var nameRecipient = nameInput.Recipient.(@id == idString).firstname;
firstname.text = nameRecipient;

var nameSender = nameInput.Recipient.(@id == idString).sender;
sender.text = nameSender;

var titleSender = nameInput.Recipient.(@id == idString).title;
jobtitle.text = titleSender;

}

```

And here is the html code where the flash movie is embedded:

```
<param name="movie" value="xmas_2111.swf" />
<param name="FlashVars" value="id=1" />
<param name="quality" value="high" />
<embed src="xmas_2111.swf" FlashVars="id=1" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="550" height="400"></embed>

```

```auto

 
If I comment out this line in the actionscript:

```

var idString:String = root.loaderInfo.parameters.id;

```auto

then replace it with a value like this:

```

var idString:String = “3”;

```auto

it reads the correct elements from my xml file as hoped!
I just can't seem to take the id value from the query string and pass it to the variable idString...so, so frustrating!
 
Any suggestions are most welcome.
Cheers,
W
```
