# Pass data to a new SWF

**URL:** <https://forum.kirupa.com/t/pass-data-to-a-new-swf/271522>\
**Category:** Uncategorized\
**Created:** [September 24, 2008, 5:14am UTC](https://forum.kirupa.com/t/pass-data-to-a-new-swf/271522 "2008-09-24T05:14:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adumi](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@adumi](https://forum.kirupa.com/u/adumi)\
**Post date:** [September 24, 2008, 5:14am UTC](https://forum.kirupa.com/t/pass-data-to-a-new-swf/271522/1 "2008-09-24T05:14:53Z")

</div>

I have one swf replacing another. The first SWF doesnt load the second one into it`s display list, is uses navigateToUrl (_self) to open the new swf instead of itself ( in the same window). I`d like the first SWF that calls the second SWF to pass to it a single variable, based on the choise of the surfer ( meaning it is dynamic). What would be the best way of doing that with AS3 ?

Basically what I did try was to pass this var to the query string of the new SWF. I succsedeed doing that, but I fail retrieving it from the query string within the new SWF. This is the code I used to pass the var :

```auto

this.addEventListener(MouseEvent.CLICK, onClick);
function onClick(myEvent:Event):void {
    var req:URLRequest = new URLRequest("newPage.html");
    var Variable:URLVariables = new URLVariables();
    Variable.varA = "A";
    req.data = Variable ;
    req.method = URLRequestMethod.GET
    navigateToURL(req, "_self");
}

```

The Url I get for the new swf, using this code is :  
[COLOR=#ff9900][http://www.mySite.com/newPage.html?varA=A[/COLOR]](http://www.mySite.com/newPage.html?varA=A%5B/COLOR%5D)  
and the code I`ve tried using for retrieving this query string data in the new swf is :

```auto

myTextField.text = this.root.loaderInfo.parameters["varA"];}

```

or:

```auto

myTextField.text = this.root.loaderInfo.parameters.varA;}

```

or:

```auto

myTextField.text = root.loaderInfo.parameters["varA"];}

```

or:

```auto

myTextField.text = root.loaderInfo.parameters.varA;

```

But, it doesnt work.  
If anyone has any idea what`s wrong in this code or of another way of doing the whoe thing, I`d be very grateful.
