8 Replies Latest reply on Jan 17, 2011 1:37 PM by snunicycler

    xml/as2 question

    snunicycler Level 3

      nevermind my last question, i figured it out. but it brought up a new one. i have a diagram like thisPicture 4.png

      that when the user clicks on one of those parts it will eventually open up a new window (with dynamic text that is parsed to an xml file) like this

      Picture 3.png

      it will have a picture in it too, i'll figure that out i'm sure. my MAIN question is... in my xml right now i only have the information for one part. (one name, description, part number, etc) and it works fine. but is there a way i can have ONE xml file for all of those parts, and have the popup know which part to display the information for? i will be adding a level and i do not know what i need to adjust on my code to make it work.

       

      my actionscript looks like this:

       

      function processXMLData(success)
      {
          if (success)
          {
              var rootNode=this.firstChild;

              var nameNode=findNode(rootNode, "name");
              name=getValue(nameNode);
             
              var ssnumberNode=findNode(rootNode, "ssnumber");
              ssnumber=getValue(ssnumberNode);

      etc.........

      if i add a level in my xml for those 8 parts ( <item1>, <item2>, <item3>, etc.) what do i need to change in the actionscript so that it displays the correct info?

        • 1. Re: xml/as2 question
          snunicycler Level 3

          OR..... i am not sure if this is possible but we already have a database with all of the necessary information. our database is microsoft SQL. can i parse the information directly from that?

          • 2. Re: xml/as2 question
            kglad Adobe Community Professional & MVP

            yes, but not directly.  you'll need server-side script to read your database.  flash can communicate with that script using the loadvars class.

            1 person found this helpful
            • 3. Re: xml/as2 question
              snunicycler Level 3

              server-side script is... asp, php, etc... right? ok, our IT guys can probably help me set that up. i think they already use one of those to load info on our website. are there any tutorials about loadvars online? preferably something that can explain what and why (everything i find says to just copy and paste, not helpful unless you are trying to do EXACTLY what they are doing). i would like to actually learn this stuff instead of just copy/paste...

              • 4. Re: xml/as2 question
                Ned Murphy Adobe Community Professional & MVP

                Here's one tutorial that might fill the bill., and you may want to check out others at the site.

                 

                http://www.gotoandlearn.com/play.php?id=20

                1 person found this helpful
                • 5. Re: xml/as2 question
                  snunicycler Level 3

                  that was really informative. it helped me understand what is going on with the database and if i copied that code i could get his result.

                  i am kind of looking for a website/tutorial/article that helps explain what "childNode", "LoadVar", "this.firstChild", etc... mean and how to use them. i can always copy paste. but i'd like to write my own code. i wish that gotoAndLearn website had a way to search for specific tutorials.

                  • 6. Re: xml/as2 question
                    Ned Murphy Adobe Community Professional & MVP

                    If you go to the main url, you should find them displayed, though it used to be better where he displayed all of them on the one page.  Now he's broken them up into pages - I find it less helpful that way, but I reckon whatever reasoning is behind it is why he makes the big bucks (?).

                     

                    Since you are dealing with AS2 in this case, it would probably be to your benefit to start searching from the far end of the collection.

                    1 person found this helpful
                    • 7. Re: xml/as2 question
                      snunicycler Level 3

                      so far after all my search this is the best (most instructional) tutorial i have found for what i am trying to learn. just in case anyone else is looking.

                       

                      here is my new code that works for PART of my movie. ssnumberNode works fine but itemNode does not. i bolded the parts that are important

                       

                      on (rollOver) {
                          function processXMLData(success)
                      {
                          if (success)
                          {
                              var rootNode=this.firstChild.childNodes[0];

                              var itemNode=findNode(rootNode, "item");
                              item=getValue(itemNode);
                             
                              var ssnumberNode=findNode(rootNode, "ssnumber");
                              ssnumber=getValue(ssnumberNode);

                             
                             
                      }
                          else
                          {
                              content="oops, this is hard";
                          }
                      }

                      function getValue(node)
                      {

                        if (node && node.firstChild)
                            return node.firstChild.nodeValue;
                        return "?";

                      }

                      function findNode(node, nodeName)
                      {
                          if (node.nodeName==nodeName)
                              return node;
                          for (var i=0; node.childNodes && i<node.childNodes.length; i++)
                          {
                              var foundNode=findNode(node.childNodes[i], nodeName);
                              if (foundNode!=null)
                                  return foundNode;
                          }
                          return null;
                      }

                      var xmlData=new XML();
                      xmlData.ignoreWhite=true;
                      xmlData.onLoad=processXMLData;
                      xmlData.load("popup.xml");
                      stop();
                      }

                      the part that says " if(node && node.firstChild) return node.firstChild.nodeValue; return "?" is the thing that is giving me trouble. the question mark shows up on my dynamic text box called "item" but the "ssnumber" one works fine. what is wrong with my code?

                      Picture 1.png

                       

                       

                      EDIT: sorry, i think this is too far off topic of my original post so i am going to start a new thread like i should have in the first place. thanks

                      • 8. Re: xml/as2 question
                        snunicycler Level 3

                        oh my gosh, i hate it when the problem is something totally stupid and small. like missing a bracket or not closing a tag correctly, in my case i had a small space in my code that should not have been there. i figured it out and now it works. the sad part is, i have been staring at my monitor since 930 this morning trying to figure it out. i have had my coworkers come in and check it out too. it evaded all of us. sheesh......