PDA

Click to See Complete Forum and Search --> : Troubles with XML parsing function arrays



SoulDance
05-07-2001, 05:24 AM
I have set up a function that loops through and sticks the XML node values into arrays .. no probs there (I've checked the debugger to ensure the values are being sent correctly into the arrays)

Unfortunately when I go to use the array values at a later stage, they are not usable - I anticipate because the values were formed inside a function, even though the array was declared outside the function...

So my question is, how do I establish the arrays in such a way as to make the values of those arrays accessible outside the function?

FlashGuru
05-07-2001, 01:20 PM
If you focus all your actions in your function towards an array which is global(not inside of the function) then you should be able to access its elements later on in your code:

eg.



//create an array on the main timeline
test=new Array()
//create a function that edits the first position in the array
function editarray(){
_root.test[0]="hello"
}
//call the function
editarray()
//trace the value of the first position in the array
trace(test[0])

SoulDance
05-08-2001, 06:44 AM
Thanks for that FlashGuru - I did try your code and by itself it works like a charm .. although when put in the context of the routine I'm running it was still giving me no end of problems..

However, there is a happy ending here ;)

I played around for (ahem) a little while longer and found the only way to get around it was to set a variable right at the end of the function indicating it was finished eg. finished="true" or something similar..

Then I stuck my subsequent array calls under a
if finished == "true"
prerequisite.. I realise this isnt exactly the most elegant solution, but it works - though I'm still baffled as to why it didnt work before........

Cheers