A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Troubles with XML parsing function arrays

  1. #1
    Junior Member
    Join Date
    Oct 2000
    Posts
    2
    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?

  2. #2
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    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.

    Code:
    //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])

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Posts
    2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center