1 Reply Latest reply on Sep 10, 2008 5:16 AM by Newsgroup_User

    trees and createComponentFromDescriptor

    jdee138
      I have an XML tree created from an XML dataprovider.
      <mx:Tree id="XMLtree1" width="150" height="100%" labelField="@label" showRoot="false" itemOpen="itemOpenEvt(event);" dataProvider="{bxml}"
      x="-1" y="61" borderStyle="none">
      </mx:Tree>

      This XML tree exists in a canvas on a viewstack.
      When I fire of an event on page 0 of my viewstack I want to go to page 4 and navigate to a particular row in my tree.
      This works fine if I visit page 4 of my viewstack look at the tree, then go to page 1 and fire the event.
      If I start at page 1 and fire the event I get a null property error.
      Hence my XML tree doesn't appear to be instantiated.
      Running a createComponentFromDescriptor on the canvas containing the xmltree doesn't work either.
      Is there some other way to instantiate my XML tree ?
        • 1. Re: trees and createComponentFromDescriptor
          Level 7

          "jdee138" <webforumsuser@macromedia.com> wrote in message
          news:ga7m92$7qd$1@forums.macromedia.com...
          >I have an XML tree created from an XML dataprovider.
          > <mx:Tree id="XMLtree1" width="150" height="100%" labelField="@label"
          > showRoot="false" itemOpen="itemOpenEvt(event);" dataProvider="{bxml}"
          > x="-1" y="61" borderStyle="none">
          > </mx:Tree>
          >
          > This XML tree exists in a canvas on a viewstack.
          > When I fire of an event on page 0 of my viewstack I want to go to page 4
          > and
          > navigate to a particular row in my tree.
          > This works fine if I visit page 4 of my viewstack look at the tree, then
          > go to
          > page 1 and fire the event.
          > If I start at page 1 and fire the event I get a null property error.
          > Hence my XML tree doesn't appear to be instantiated.
          > Running a createComponentFromDescriptor on the canvas containing the
          > xmltree
          > doesn't work either.
          > Is there some other way to instantiate my XML tree ?

          I suspect this is your problem, from the FAQ I am working on:

          Q: I need to set a property or add an event listener on a component
          that is in a ViewStack/TabNavigator/Accordion. When the component is not
          the first child of the Navigator Container, I get a null object error
          (#1009). What causes this, and how can I fix it?

          A: By default, the Navigator containers only create the children of
          each pane as that pane is viewed. The easy way to fix this is to set the
          creationPolicy on the Navigator to "all." However, this will cause your
          application to take longer to load. A better way to fix this is to wait for
          a later event, such as creationComplete on the component you want to access,
          or to use binding to "pull" the data into the component.
          The way I handle it is to call invalidateProperties() on change of the
          ViewStack. I then override commitProperties() and call an "initializer" for
          each pane. In the body of each initializer function, I check to see if the
          selectedItem for the viewStack is the one my initalizer cares about. If
          not, I return from the function immediately. Inside that initializer
          function, I set properties and add listeners as appropriate.