# Reusing an object/variable name

**URL:** <https://forum.kirupa.com/t/reusing-an-object-variable-name/288600>\
**Category:** flash\
**Created:** [May 18, 2009, 7:56pm UTC](https://forum.kirupa.com/t/reusing-an-object-variable-name/288600 "2009-05-18T19:56:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mistermind](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Mistermind](https://forum.kirupa.com/u/Mistermind)\
**Post date:** [May 18, 2009, 7:56pm UTC](https://forum.kirupa.com/t/reusing-an-object-variable-name/288600/1 "2009-05-18T19:56:56Z")

</div>

Hello again!  
Out of some curiosity and the use of possible standard key variables so I don’t have to create several instances to the same class, I was trying the following:

```auto
var urlRequest:URLRequest = new URLRequest(website + "/news_test.txt");
var urlLoader:URLLoader = new URLLoader();
var urlVars:URLVariables = new URLVariables();

urlRequest.method = URLRequestMethod.POST;
urlLoader.addEventListener(Event.COMPLETE, newsLoaded);
urlLoader.dataFormat=URLLoaderDataFormat.VARIABLES;

// First use of Request/Loader
function newsLoaded(event:Event):void {
    trace(event.target.data.news);
    event.currentTarget.removeEventListener(Event.COMPLETE,newsLoaded);
}
urlLoader.load(urlRequest);

// Second use
loginButton.addEventListener(MouseEvent.CLICK, loginOnClick, false, 0, true);
function loginOnClick(event:MouseEvent):void{
    urlVars.u = usernameTextField.text;
    urlVars.p = passwordTextField.text;
    urlRequest = new URLRequest("validate.asp"); // Does not work.
    urlRequest.data = urlVars;
    urlLoader.load(urlRequest); // Does not work.
    urlLoader.addEventListener(Event.COMPLETE, loginLoaded);
}

```

That approach gave me the following error:

```auto
Error:[Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs](http://www.visible-form.com/blog/error-2101-the-string-passed-to-urlvariablesdecode-must-be-a-url-encoded-query-string-containing-namevalue-pairs/)
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables()
    at flash.net::URLLoader/onComplete()

```

This error does not occur if I try the same thing but instead of reusing urlRequest and urlLoader I create new instances of the same classes.  
\*\*  
My question is:\*\*  
Is there a better approach to this on AS3? Something tells me I’m just heading the wrong way there…
