1 Reply Latest reply on May 12, 2009 12:28 PM by Pinnennet

    Tree node icon from XML

    Trensic Level 1
      Is there a way to define a linkage id to set the icon for the tree component in external XML? This is what I tried and it does not work.

      <node label="Test" data="SomeID" icon="SomeLinkageID">

      The tree node is using the default folder icon. I know I could set the icon after it is loaded but why cann't I just throw in something to define the icon in the XML?

      Thanks
        • 1. Re: Tree node icon from XML
          Pinnennet Level 1

          Im having the same problem right now (three years later).

           

          Here is the code ive got so far. But i can only make it to load icons in the first "folder":

           

           

           

          //Flash code:

           

          my_xml = new XML();
          my_xml.ignoreWhite = true;
          my_xml.load("tree.xml");

          my_xml.onLoad = function(){
          myTree.dataProvider = this.firstChild;


          var folders = my_xml.firstChild.firstChild;
          var docs = folders.childNodes;

          for (var i=0; i < docs.length; i++){
          currDoc = docs[i];
          trace(docs[i]);

          var docIcon = currDoc.attributes.pic;

          switch(docIcon){
          case "pdf":
          myTree.setIcon(currDoc, "pdfIcon");
          break;
          case "word":
          myTree.setIcon(currDoc, "wordIcon");
          break;
          case "excel":
          myTree.setIcon(currDoc, "excelIcon");
          break;
          case "ie":
          myTree.setIcon(currDoc, "ieIcon");
          break;
          }//switch
          } //for
          };//onLoad

           

           

          XML code:

           

          <?xml version="1.0" encoding="utf-8"?>
          <node label="» Dokument typer">
          <node label="» links - document">
          <node label="test.url" url="http://www." pic="ie" info="test text" />
          <node label="test.doc" url="test.doc" pic="word" info="test text" />
          <node label="test.excel" url="test.xls" pic="excel" info="test text" />
          <node label="test.pdf" url="test.pdf" pic="ie" info="test text." />
          </node>
          <node label="» Links - document">
          <node label="test URL" url="http://www." pic="ie" info="test text." />
          <node label="test URL" url="http://www." pic="ie" info="test text." />
          </node>
          </node>