1 Reply Latest reply on May 1, 2007 9:39 AM by khaledk

    Initialize a component of a particular state

    khaledk Level 1
      Hi all,

      In main application there are two states.
      First one called WrapperState (has Wrapper component), and the second one called DetailsState(has Details component) and details component based on wrapper component.

      In Wrapper component (WrapperState) I will pass some data to details component before I will go to (DetailsState).

      The problem here, once I tried to pass the data the following error displayed:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at Main/::selectHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent() .................

      I have tried to do some experience by going to DetailsState without passing anything and return to WrapperState and then pass those data (No Problem!). And by that, I conculade that details component has not initialized.
      I have tried to use creationPolicy Method and set the value to "all" in details component, but even with that the error still appearing.

      An example of how details component has been defined.

      <mx:State name="DetailsState" basedOn="MapState">
      <mx:AddChild position="lastChild">
      <face:Details id="details" horizontalCenter="0" verticalCenter="0" />
      <mx:RemoveChild target="{wrapper}"/>

      the change state event (customized event) would be fired from the wrapper component and handled by main application.

      I hope if you can help me in this problem.

      Thanks in advance.
        • 1. Re: Initialize a component of a particular state
          khaledk Level 1
          I think the following question will clear the above:

          How to initialize a component in particular state before entering that state?

          I gave details component an id, and after wrapper fired its customized event, I checked if details initializtion result and it gives me false.
          I have tried in ActionScript to initialize details component by ---> this.details = new Details(); But it did not work.