Simple (?) actionscript question

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.

regards

Henrik, sweden

Hi

Try declaring array as:

_global.myArray = new Array();


aShIsH

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;

_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 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…

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…

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