1 Reply Latest reply on Jan 7, 2008 7:19 AM by VarioPegged

    Synching events?

      I am new to Flex, and I am trying to grasp some key concepts. What I have is a flex file uploader that has two event listeners:

      f.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadCompleteData);
      f.addEventListener(Event.COMPLETE, completeHandler);

      I am tracking some data in the UploadCompleteData function that needs to get sent to a Coldfusion .CFM file using a URLRequest/navigateToURL.

      What happens is, the URL is getting called before the uploadCompleteData event is finished running! So the data getting passed to my coldfusion script is incomplete.

      I don't know what is going on behind the scenes here, my guess is that two events are getting kicked off as threads, one is completing before the other. How can I make the event wait on the completion of the other one, without adding a "Please click here to continue" to slow things down? Does this make any sense at all? ;)

      Thanks for any help!
        • 1. Re: Synching events?
          VarioPegged Level 2
          Mike, ActionScript executes asynchronously.

          Try doing the following:
          f.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadCompleteData);

          function uploadCompleteData(event:DataEvent):void
          //Pseudo-code to get your data
          someURLData = event.data;
          //Function call to navigate to URL

          function doURLNavigation(data:Object):void
          //Handle your URLRequest/navigateToURL here

          I'm not sure where f.addEventListener(Event.COMPLETE, completeHandler) figures in all this, but the above should give you a starting point.