# Take a variable out of a function! OMG!

**URL:** <https://forum.kirupa.com/t/take-a-variable-out-of-a-function-omg/220141>\
**Category:** Uncategorized\
**Created:** [March 23, 2007, 3:40am UTC](https://forum.kirupa.com/t/take-a-variable-out-of-a-function-omg/220141 "2007-03-23T03:40:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![digital\_soul18](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@digital\_soul18](https://forum.kirupa.com/u/digital_soul18)\
**Post date:** [March 23, 2007, 3:40am UTC](https://forum.kirupa.com/t/take-a-variable-out-of-a-function-omg/220141/1 "2007-03-23T03:40:32Z")

</div>

Hi d00ds,  
I have a array that gets passed straight into this function

```auto

function handleResult(re : ResultEvent)
{
    QuestionSet = re.result;
    trace(QuestionSet[0]['Question']);
}

```

Now I wan’t to take the ‘QuestionSet’ array out of this function and expose it on the first frame (or on the \_root. domain) so I can call it from OUTSIDE the function. So for example:

```auto

function handleResult(re : ResultEvent)
{
    QuestionSet = re.result;
    trace(QuestionSet[0]['Question']); //this works
}
trace(QuestionSet[0]['Question']); //this doesnt work, but i want it to work!!

```

Now I’ve tried declaring \_global variables, with no luck!:

```auto

function handleResult(re : ResultEvent)
{
    QuestionSet = re.result;
    _global.Question = QuestionSet
    trace(_global.Question[0]['Question']); //this works
}
trace(_global.Question[0]['Question']); //this doesn't work.

```

Any ideas??

Oh and another note:

I can’t use the ‘return’ line in the function because it still doesnt work because what I use is AMFPHP and that takes al my variables from my PHP and straight inserts them into the above function. This is the whole code:

```auto

stop();

import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;
 
var gatewayUrl:String = "http://localhost/flashservices/gateway.php"
 
NetDebug.initialize();
var _service:Service = new Service(gatewayUrl, null, 'HelloWorld', null , null);
var pc:PendingCall = _service.say("Hello world!");
pc.responder = new RelayResponder(this, "handleResult", "handleError");

function handleResult(re : ResultEvent)
{
    QuestionSet = re.result;
    _global.Question = QuestionSet
    trace(_global.Question[0]['Question']);
}

function handleError(fe:FaultEvent)
{
    trace('There has been an error');
}

    

```

I can’t just return the array because first i need to PUT IN the array in order to return it from the function which defeats the purpose!
