1 Reply Latest reply on Mar 24, 2010 2:07 PM by skider

    If Flex is synchronous, need help understanding the order I'm seeing things in this example?

    rickcr Level 1

      I'm stumped by this. All my googling and searching on forums seems to claim that Flex is single-threaded from the point of the developer's concern - other than of course things like asynch service calls, timers, etc.

       

      But look at this...

       

      I have a button which triggers this code:

       

      public function testCreateMethod():void {
          trace("testCreateMethod: creating TestPrompt");
          var prompt:TestPrompt = new TestPrompt();
          trace("testCreateMethod: addingChild to box.");
          myBox.addChild(prompt);
          trace("testCreateMethod: done creating TestPrompt .. moving on. See this last?");
      }
      

       

      The TestPrompt class above has the following relevant portion of code:

       

      private function initPopUp():void {
          trace("initPopUp() called");
      }
      
      <mx:Canvas>
          <mx:PopUpButton id="popUpButton" label="MyPopUpButton" openAlways="true" creationComplete="initPopUp();"/>
      </mx:Canvas>
      

       

       

      When the above testCreateMethod takes place, I would expect that when myBox.addChild(prompt) takes place, that caretionComplete initPopUp() would occur and I'd see the log "initPopUp()" in the logs BEFORE 'done creating TestPrompt... moving on' Yet, that is not the case...

       

      The last trace in testCreateMethod is occurring BEFORE the initPopUp trace statement. It looks like:

       

      [trace] testCreateMethod: creating TestPrompt
      [trace] testCreateMethod: addingChild to box
      [trace] testCreateMethod: done creating TestPrompt .. moving on
      [trace] initPopUp() called
      

       

      Why am I seeing this behavior? I guess I can assume things are still happning synchronously yet the order in which they fire has me stumped.