# Simple (?) actionscript question

**URL:** <https://forum.kirupa.com/t/simple-actionscript-question/65566>\
**Category:** Uncategorized\
**Created:** [September 27, 2004, 8:44pm UTC](https://forum.kirupa.com/t/simple-actionscript-question/65566 "2004-09-27T20:44:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henxon](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@Henxon](https://forum.kirupa.com/u/Henxon)\
**Post date:** [September 27, 2004, 8:44pm UTC](https://forum.kirupa.com/t/simple-actionscript-question/65566/1 "2004-09-27T20:44:40Z")

</div>

Hi

I want to access _pArray_ outside the _onData()_-function:  
\*  
imgArray = new pArray();

lv = new LoadVars();  
lv.load(“filearray.php”);

lv.onData = function(text){

```
 pArray = text.split("&");
 _root.textArea1.text = "pArray:"+pArray;

```

}

imgArray = pArray;  
\_root.textArea2.text = “imgArray:”+imgArray;  
\*

I tried to create an imgArray outside and use that one, but it didn’t work. What should I do to be able to access the pArray outside the function? The textareas are just for showing what the arrays contain, wich will be dynamicly loaded images, using a PHP script. I’m trying to create [this gallery function.](http://www.kirupaforum.com/forums/showthread.php?t=57082&highlight=dynamic+image)

regards

Henrik, sweden

---

<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:** [September 28, 2004, 6:49am UTC](https://forum.kirupa.com/t/simple-actionscript-question/65566/2 "2004-09-28T06:49:31Z")

</div>

Hi

Try declaring array as:

\_global.myArray = new Array();

* * *

aShIsH

---

<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:** [September 28, 2004, 6:54am UTC](https://forum.kirupa.com/t/simple-actionscript-question/65566/3 "2004-09-28T06:54:59Z")

</div>

what the heck is a ‘pArray’ ?

**imgArray = new Array();** //no ‘p’

lv = new LoadVars();  
lv.load(“filearray.php”);

lv.onData = function(text){

**imgArray** = text.split("&"); //do you have any more explicit variables?  
//toss = \_root.textArea1.text = “pArray:”+pArray;

}

// toss = **imgArray = pArray;**  
\_root.textArea2.text = “imgArray:”+imgArray;

---

<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:** [September 28, 2004, 9:20am UTC](https://forum.kirupa.com/t/simple-actionscript-question/65566/4 "2004-09-28T09:20:17Z")

</div>

\_global won’t help me, sorry, have tried… pArray is the array that’s created for holding the images. the imgArray have I added myself, just to try to get the pArray to be accessable… but my way won’t work… I have just followed the [dynamic gallery tutorial @ kirupa](http://www.kirupaforum.com/forums/showthread.php?t=57082&highlight=dynamic+image) as said before…

the _\_root.textArea1.text = “pArray:”+pArray;_ thats inside the onData will print the correct array, but the _\_root.textArea2.text = “imgArray:”+imgArray;_ in the end won’t print anything…

---

<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:** [September 28, 2004, 8:52pm UTC](https://forum.kirupa.com/t/simple-actionscript-question/65566/5 "2004-09-28T20:52:03Z")

</div>

you don’t need a global, if you’re using the array within that swf. which I think you are… it makes no sense to use another array to hold the info… if **pArray** is getting the data… it will still exist after the mc.onLoad (I’d use the onLoad rather than onData, 'cause then you know you got all the info) so just use it…

---

<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:** [October 4, 2004, 8:09pm UTC](https://forum.kirupa.com/t/simple-actionscript-question/65566/6 "2004-10-04T20:09:03Z")

</div>

Henxon,  
it appears that you should be using imgArray NOT pArray. The way you have it set up you declare imgArray oustide the onData but you never declare pArray. When you use pArray as a variable in the onData function it’s a local variable that disappears when the function ends. Try changing pArray = … to imgArray = … in the onData function
