5 Replies Latest reply on Jun 20, 2006 7:58 PM by

    Populating and associative array (?)

      I'm adapting a class explained in 'Flash Application Design Solution". The code is used for populating a menu system.

      In the original code, the menu system array is hardcoded in this fashion:
      var MenuData:Array = [{title:"Advanced Flash Interface Design"}, {title:"Flash 3D Cheats Most Wanted"}, {title:"Flash 8 Essentials"}, {title:"Flash Cartoon Animation"}];

      Is this an associative array?

      In my code, I would like rather use an XML file to populate MenuData, but something is missing in my comprehension. The code below doesn't work since there is not title 'label' associated to my array data.

        • 1. Re: Populating and associative array (?)
          Level 7
          > In the original code, the menu system array is hardcoded in this fashion:
          > var MenuData:Array = [{title:"Advanced Flash Interface Design"},
          > {title:"Flash
          > 3D Cheats Most Wanted"}, {title:"Flash 8 Essentials"}, {title:"Flash
          > Cartoon
          > Animation"}];
          >
          > Is this an associative array?

          No .. its just an array .. its not associative at all

          > In my code, I would like rather use an XML file to populate MenuData, but
          > something is missing in my comprehension. The code below doesn't work
          > since
          > there is not title 'label' associated to my array data.

          As we have no idea what is in your xml file, we cannot tell what will be in
          your array.
          --
          Jeckyl


          1 person found this helpful
          • 2. Re: Populating and associative array (?)
            Thank you for answering. My problem resides on the object literals. How to implement them.

            The XML file looks like what is below. My code, for the moment, reads the node <theme> and the two attributes must be coded as follow: MenuData[{nom:.....}{chemin:........}]



            • 3. Re: Populating and associative array (?)
              Level 7
              I don't see anything in there that is a 'title' .. so how do you expect
              there to suddenly be a title in your array that you populate from that xml
              data?

              I think you need to do some thinking about what you want to have happen and
              try to implement that first.
              --
              Jeckyl


              1 person found this helpful
              • 4. Populating and associative array (?)
                Sorry to have been unclear. "title:......" will be replaced in my code by "nom:.........."
                To rephrase it. There is a structure that is hardcoded this way:
                MenuData[{nom:"........",chemin:"........."},{nom:"........",chemin:"........."}]

                How to populate dynamically such an array from the XML code sample given?
                • 5. Re: Populating and associative array (?)
                  I've found the solution:
                  MenuData.push({title:photos .attributes.nom});