5 Replies Latest reply on Jul 5, 2011 10:14 PM by relaxatraja

    Hide specific XML nodes but display others

    BlackOpsRanger

      I have been looking for a reference for this all over Google and even through the Adobe Forums but I can't find anything.

      I'm using Flash CS4, AS2. I'm calling an XML document to populate 2 text areas (textArea). In one textArea I need to display the firstChild (or ROOT node) and three childNodes after that. In the other textArea, I need to display the fourth childNode only.

       

      I am good to go for the second textArea, the one that only shows the fourth childNode. What I cannot figure out is how to hide that fourth childNode from my other textArea that calls for the same XML file. My code is written below, actionscript and XML. My textArea boxes are named "myText" and "myText2". "myText2" is the one that is working properly. I need to show only the <title> <description> and <price> tags in the "myText" box, not the <link> tag.

       

      Thanks in advance for all help!!

       

      Flash AS2

      //Set Image Properties
      myImageBox.html = true;
      myImageBox.wordWrap = true;
      myImageBox.multiline = true;
      myImageBox.label.condenseWhite = true;
      myImageBox.setStyle("borderStyle","none");
      myImageBox.setStyle("backgroundColor","0xCCCCCC");

       

      // Set TextArea Properties
      myText.html = true;
      myText.wordWrap = true;
      myText.multiline = true;
      myText.label.condenseWhite = true;
      myText.setStyle("borderStyle","none");
      myText.setStyle("backgroundColor","0xCCCCCC");

       

      //Set Link Box Text Area Properties
      myText2.html = true;
      myText2.wordWrap = true;
      myText2.multiline = true;
      myText2.label.condenseWhite = true;
      myText2.setStyle("borderStyle","none");
      myText2.setStyle("backgroundColor","0xCCCCCC");

       

      //Call on External CSS document
      NewItem = new TextField.StyleSheet();
      NewItem.load("featuredItem.css");
      myText.styleSheet = NewItem;
      myText2.styleSheet = NewItem;

       

      //Load XML Image Properties
      myImageBox.text = "<img src = 'smallShirt.jpg'>";

       

      //Load XML Properties
      featuredContent = new XML();
      featuredContent.ignoreWhite = true;
      featuredContent.load("featuredItem.xml");
      featuredContent.onLoad = function(success)
      {
              if(success)
              {
                      myText.text = featuredContent;
                      myText2.text = featuredContent.firstChild.childNodes[4];
              }
      }

       

       

       

       

      XML

      <featureItem>
          <title>This is the Title!</title>
          <description>Describe the item here</description>
          <price>Put the price of the new item here</price>
          <br/>
          <link><a href="http://charmcity3d.com">View Here</a></link>
      </featureItem>

        • 1. Re: Hide specific XML nodes but display others
          relaxatraja Level 5

          Change like below:

          //Set Image Properties
          myImageBox.html = true;
          myImageBox.wordWrap = true;
          myImageBox.multiline = true;
          myImageBox.label.condenseWhite = true;
          myImageBox.setStyle("borderStyle","none");
          myImageBox.setStyle("backgroundColor","0xCCCCCC");

          // Set TextArea Properties
          myText.html = true;
          myText.wordWrap = true;
          myText.multiline = true;
          myText.label.condenseWhite = true;
          myText.setStyle("borderStyle","none");
          myText.setStyle("backgroundColor","0xCCCCCC");

          //Set Link Box Text Area Properties
          myText2.html = true;
          myText2.wordWrap = true;
          myText2.multiline = true;
          myText2.label.condenseWhite = true;
          myText2.setStyle("borderStyle","none");
          myText2.setStyle("backgroundColor","0xCCCCCC");

          //Call on External CSS document
          NewItem = new TextField.StyleSheet();
          NewItem.load("featuredItem.css");
          myText.styleSheet = NewItem;
          myText2.styleSheet = NewItem;



          //Load XML Image Properties
          myImageBox.text = "<img src = 'smallShirt.jpg'>";



          //Load XML Properties
          featuredContent = new XML();
          featuredContent.ignoreWhite = true;
          featuredContent.load("featuredItem.xml");
          featuredContent.onLoad = function(success)
          {
                  if(success)
                  {
                          len=featuredContent.firstChild.childNodes.length;
                          str="";
                          for (i=0;i<len-1;i++){
                              str+=featuredContent.firstChild.childNodes[i].firstChild.nodeValue+"\n";
                          }
                          myText.text = str;
                          myText2.text = featuredContent.firstChild.childNodes[3];
                  }
          }

          and xml should be

           

          <featureItem>
              <title>This is the Title!</title>
              <description>Describe the item here</description>
              <price>Put the price of the new item here</price>
              <link><a href="http://charmcity3d.com">View Here</a></link>
          </featureItem>

          Thatz it

          1 person found this helpful
          • 2. Re: Hide specific XML nodes but display others
            BlackOpsRanger Level 1

            Thanks for the response, and sorry for the delay.

            Your code works, except that it keeps putting the "\ n"

            in the results view between the XML content nodes.

            Am I supposed to change that out with something?

            Also, when using your code, all of my styleSheet

            settings no longer work. Is there an adjustment for this?

            Thanks

            • 3. Re: Hide specific XML nodes but display others
              relaxatraja Level 5

              I'm not to look into your css, I Just tried with your code and the xml. Post the css.

              • 4. Re: Hide specific XML nodes but display others
                BlackOpsRanger Level 1

                Actually, it was my mistake. Your answer was perfect! Thank you so much for your help,

                I really appreciate it!