# \[FMX\] Array scope problem

**URL:** https://forum.kirupa.com/t/fmx-array-scope-problem/13817
**Category:** flash
**Created:** [February 18, 2003, 4:29pm UTC](https://forum.kirupa.com/t/fmx-array-scope-problem/13817 "2003-02-18T16:29:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![or1onas](https://avatars.discourse-cdn.com/v4/letter/o/c57346/32.png) [@or1onas](https://forum.kirupa.com/u/or1onas)
#### Post date: [February 18, 2003, 4:29pm UTC](https://forum.kirupa.com/t/fmx-array-scope-problem/13817/1 "2003-02-18T16:29:57Z")

</div>

Greeting to all of you guys!  
I’ve been working with fmx for almost 4 months now and i really love it. I’ve recently started working with PHP and mySQL, and this is where it got even better!!! =)  
Unfortunately, i’ve stepped into a problem, and i can’t solve it, so i’d like to hear any ideas…  
The story is:  
I’ve created a new loadVars() object named eg. “getThem” in the root timeline, which receives the variables from a php script, and puts them in an array. This array is named eg. “varsArray” and is created inside the “getThem.onLoad” function.  
The problem is that i need to use this array inside another movieclip, but no matter what, as soon as the “getThem.onLoad” function ends, the array is destroyed…  
Is there any way to keep this array out of the function???  
I’ve tried “\_global.varsArray” or “\_root.varsArray” but it wouldn’t work…  
Has anyone got any ideas???

Thanx in advance.  
Or1onas.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2003, 9:33pm UTC](https://forum.kirupa.com/t/fmx-array-scope-problem/13817/2 "2003-02-18T21:33:30Z")

</div>

Did you try setInterval…?

Just a quick test, tell me how it goes.

myLoadVars = myLoadVars2 = new LoadVars();  
myLoadVars.randomVariable = new Date().getTime();  
myLoadVars.sendAndLoad(“phpfile.php”, myLoadVars2, “GET”);//Please keep it as GET  
init = function{  
//Remove the for…in loop if you have another idea for an array creation process, don’t forget to target myLoadVars2!  
for(vars in myLoadVars2){  
myArrayTest = myLoadVars[vars].split(",");  
trace(myArrayTest)  
}  
}  
setInterval(init, 1000);

Sorry, Untested, I don’t have flash installed on this pc…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2003, 10:14pm UTC](https://forum.kirupa.com/t/fmx-array-scope-problem/13817/3 "2003-02-18T22:14:29Z")

</div>

Can you post the code you’re using?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2003, 10:42pm UTC](https://forum.kirupa.com/t/fmx-array-scope-problem/13817/4 "2003-02-18T22:42:45Z")

</div>

theTracks.load(“[http://localhost/tracks.php?trackID=](http://localhost/tracks.php?trackID=)”+rand);  
theTracks.onLoad = function() {  
tracksArray = new Array();  
for (var b in this) {  
if (b != “onLoad”) {  
tracksArray.push(this\*\*);  
}  
}  
\_global.playlist = tracksArray; //tried that, but it won’t work  
};

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2003, 10:48pm UTC](https://forum.kirupa.com/t/fmx-array-scope-problem/13817/5 "2003-02-18T22:48:26Z")

</div>

Hmm, try:

theTracks = new LoadVars();  
theTracks.load(“[http://localhost/tracks.php?trackID=](http://localhost/tracks.php?trackID=)”+rand);  
tracksArray = new Array();  
this.onEnterFrame = function(){  
for (b in theTracks) {  
tracksArray.push(this\*\*);  
}  
}

Also, did you try the attempt posted above…?
