5 Replies Latest reply on Mar 2, 2011 9:42 AM by Flex harUI

    How does Flex decide when to draw a scrollbar?

    jaywhy13

      First my problem...

      I have a tree whose data changes because I changed the contents of a custom object in the data provider's array collection. The scrollbar does not update itself when the tree expands beyond the view of the canvas. It doesn't update until I close the branch and then reopen it. Then, the scrollbar updates itself.

       

      What I've tried...

      So far, I figure that since the changes are occurring deep within the data provider, no Collection Event is getting dispatched. Since the structure is so..

      dataProvider = arrayCollection;

      arrayCollection[ 0 ] = parentNode : TreeNode;

      parentNode.children = ... // array collection of other TreeNodes

       

      So I've tried dispatching my own event when the addition of the nodes is through using the following...

      layerDirectoryArr.refresh(); // layerDirectory is the first child in the array collection in the dataProvider (parentNode)
      sidePanel.directoryTree.invalidateDisplayList();
      sidePanel.directoryTree.invalidateSize();
      layerDirectoryArr.dispatchEvent(new CollectionEvent(CollectionEventKind.UPDATE, false, false, CollectionEventKind.UPDATE, 0, 0, [layerDirectoryArr[0]]));

       

      I've also tried adding buttons to invalidateDisplayList(), invalidateSize() for the tree and neither work.

       

       

      More explanation on the code below..

      The data provider is an array collection of custom object that all have a "children" field (array collection) of the same custom objects. I have a Tree that is within a canvas. The Tree uses a custom renderer. The tree sits in the same position as a List. I use a "useTree" var to toggle the visibility, essentially to choose either the List or the Tree to be displayed within the Canvas. I set both of them at 0,0.

       

      <mx:Canvas width="100%"
                     id="hBox"
                     backgroundAlpha="0.7"
                     height="80%"
                     verticalScrollPolicy="off"
                     horizontalScrollPolicy="off"
                     backgroundColor="0x55FF66"
                     dataChange="validateNow()">
              <mx:List id="list"
                       width="100%"
                       height="100%"
                       labelField="name"
                       x="0"
                       y="0"
                       visible="{!useTree}"
                       backgroundAlpha="0.8"
                       itemRenderer="components.tree.CustomListItemRenderer"
                       creationComplete="listComplete(event)"
                       dataChange="validateNow()"/>
              <mx:Tree id="tree"
                       width="100%"
                       labelField="name"
                       showRoot="false"
                       visible="{useTree}"
                       backgroundAlpha="0.8"
                       x="0"
                       y="0"
                       creationComplete="treeComplete(event)"
                       dataProvider="{treeDataProvider}"
                       itemRenderer="{treeClass}"
                       valid="logTreeEvent(event)"
                       change="logTreeEvent(event)"
                       variableRowHeight="false">

       

              </mx:Tree>
          </mx:Canvas>