This content has been marked as final. Show 4 replies
In fact, "item" must be an object in your tree, for example, myTree.selectedItem, or dataProvider. But if you get errors just try this...
Don't call expandChildrenOf immediately after you set the dataProvider for the tree component, and put your statement "expandChildrenOf" inside a try / catch block. This will prevent for getting errors if there aren't.
The error occurs in the Flex file Tree.as at line 1383.
I can now see that the null object is not item - dataProvider, this contains the correct data. The problem is that iterator is null and therefore iterator.view is a null reference.
Is there any way to solve this problem?
My ArrayCollection is built in pretty much the same way as shown in:
Flex 2 Developer's Guide > Building User Interfaces for
Flex Applications > Using Data Providers and Collections > Using hierarchical data providers > Data descriptors and hierarchical data provider structure > Creating a custom data descriptor
But I have used the defaultDataDescriptor and my arrays are not built from literals.
I have tried calling myTree.validateNow() immediately before expandChildren, but it still fails in Tree.as with iterator = null, although iteratorValid = true.
Okay solved the problem.
To make expandChildren work, you have to do things in this order. First create the Tree and set any Properties you need. Then you must add the Tree to its container, then call validateNow() and then finally you can call expandChildren.
Thanks very much for you help. Until you replied I was stuck on the thought that it had to be item that was wrong.