3 Replies Latest reply on Jul 17, 2006 7:07 PM by singaraju

    MX:Tree api changes

    JKohn99 Level 1

      In my Flex 1.5 apps I was dynamically building trees using the following methods:

      newNode = someTree.addTreeNode(someName,someObject);

      nextNode = newNode.addTreeNode()


      So are there any alternatives when I need to build my own trees using AS objects instead
      of a xml structure?
        • 1. Re: MX:Tree api changes
          One of the options you have now for dynamically building a Tree using AS Objects is ArrayCollection dataProvider for Tree.

          // 1. create a new ArrayCollection

          private var ac:ArrayCollection = new ArrayCollection();

          // 2. use ArrayCollection's addItem to add Objects to the dataProvider

          ac.addItem( newObject);

          // 3. finally set the Tree's dataProvider to the newly constructed ArrayCollection
          myTree.dataProvider = ac;

          • 2. Re: MX:Tree api changes
            JKohn99 Level 1
            After posting this message I did a bit more digging and discovered the ITreeDataDescriptor interface. There is an example in the flex doc about creating a custom datadescriptor.

            In my case I have a variety of object hierarchies I want to display in a tree so my soution was to create a wrapper object the implements the methods (i.e. children) that the tree data descriptors
            expect. I also created my own dataDescriptor so give me more control over addChild and removeChild operations.
            • 3. Re: MX:Tree api changes
              I have a question regarding theDIRECT BINDING of a string value to a class name dynamically in Flex.I have to create an instance of the class based on the String value i get inside a function,which is like the STRING is same as the ClassName in .But still Iam unable to instantiate and am failing to convert the string to he class name. Iwas trying to achieve this but did'nt find any methos in the API also.

              If anyone has got it working can you guz pls help me achieve it.