# Variable Pass by Value

**URL:** <https://forum.kirupa.com/t/variable-pass-by-value/261560>\
**Category:** flash\
**Created:** [May 28, 2008, 9:06pm UTC](https://forum.kirupa.com/t/variable-pass-by-value/261560 "2008-05-28T21:06:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![one\_way\_7](https://avatars.discourse-cdn.com/v4/letter/o/dec6dc/32.png) [@one\_way\_7](https://forum.kirupa.com/u/one_way_7)\
**Post date:** [May 28, 2008, 9:06pm UTC](https://forum.kirupa.com/t/variable-pass-by-value/261560/1 "2008-05-28T21:06:13Z")

</div>

Hello,  
I’m trying to take variables from an external php file and load them into flash. I got most of it working, however i’v ran into a few issues with passing my variables around.

First I declare my global vars on the first keyframe:

```auto

onLoad()
{
_global.thedata = new Array();
_global.anum = 0;
}

```

Then I run my copy function

```auto

onEnterFrame()
{
getdata();
sites_txt.text = _global.thedata[1];
}

```

```auto

function getdata()
{
	l = new LoadVars();
	l.onLoad = function() 
	{
		
	for(i=0; i<15; i++)
	{
                 _global.thedata* = this["result"+i];
           }
}

```

I am able to confirm that the output from this[“results”+i] is correct. I’m also able to check its entering the array \_global.thedata\* correctly (if I run some test after the for loop). However, in its current form setting the text box with the value of thedata[1] (after getdata() function) doesn’t appear to be working. All I get is a clear input or sometimes an undefined. Could it be that \_global.thedata\* = this[“result”+i]; is passing by reference, thus when the function scope deallocates, the original variables are deallocated with it. Is there a way to pass-by-value? or is there something else i’m missing.  
Please come be my Link! 🔗  
Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![hasch2o](https://avatars.discourse-cdn.com/v4/letter/h/ba8739/32.png) [@hasch2o](https://forum.kirupa.com/u/hasch2o)\
**Post date:** [May 29, 2008, 1:32am UTC](https://forum.kirupa.com/t/variable-pass-by-value/261560/2 "2008-05-29T01:32:24Z")

</div>

Hey One\_way\_7

\_global doesn’t exist any more in AS3  
try this link: [http://greenethumb.com/article/11/global-variables-in-as3](http://greenethumb.com/article/11/global-variables-in-as3)

hth  
Carlo

---

<div class="post-metadata">

**Author:** ![one\_way\_7](https://avatars.discourse-cdn.com/v4/letter/o/dec6dc/32.png) [@one\_way\_7](https://forum.kirupa.com/u/one_way_7)\
**Post date:** [May 29, 2008, 4:22pm UTC](https://forum.kirupa.com/t/variable-pass-by-value/261560/3 "2008-05-29T16:22:35Z")

</div>

Thanks! Unfortuantly, it looks like I posted this in the wrong spot. I’m using AS2.0
