3 Replies Latest reply on Apr 13, 2009 2:53 PM by ergo_eleven

    Redraw / message-pump issues

      I am trying to solve a persistent issue in which I can't get the Flex UI to redraw in an acceptably-timely manner.

       

      My application consists of groups of asynchronous tasks that execute in a specific order and post status in-between each task -- pretty simple.  A javascript application layer posts the status updates to a simple Flex UI.

       

      In my Flex UI, callback handlers display status text by assigning the status-text strings to a member variable that is bound to a text control.

       

      In 99% of the cases, this works perfectly -- but for one particular set of status events, strings are being posted to the bound data-member, but the text control is seemingly never redrawn.

       

      Here's an example set of events:

       

      1: Receiving request data ...

      2: Processing contents ...

           [several-second pause here]

      3: Sending response ...

      4: Response data sent.

       

      Instead of the above, I see this on the screen:

       

      1: Receiving request data ...

           [pause happens here instead]

      4: Response data sent.

       

      I put logging statements in and all the messages (1-4) are getting posted to the bound member variable in the right order.  (The timing also shows that the pause comes AFTER the second message -- as it should -- so the issue isn't just that lines 2 and 3 are being displayed too quickly for the eye to catch them.)

       

      My first instinct was to set Javascript timers between each status update to give the Flex UI time to redraw.  I did that -- for every state change, no less -- and got exactly the same behavior.  I also tried explicitly invalidating the text control after each status update.  Also with no success.

       

      The only thing that DOES work is to put a JavaScript "confirm()" call before setting the setTimeout() timers after each status is posted.  Then, the Flex UI appears to refresh immediately -- but I have to click through the confirm() dialog, so that's obviously not acceptable.

       

      So for those of you that made it this far into my explanation: Thank you!  My question is:

       

      Is there some esoteric Flex-message-pumping rule I'm unaware of here that's preventing my text control from being redrawn in some instances?

       

      And if not, is there a way to force a text control to redraw itself?

       

      Any help is greatly appreciated.

        • 1. Re: Redraw / message-pump issues
          ergo_eleven Level 1

          In one of my projects i have encountered a problem that flash doesn't process server response until user moves mouse over it.

          SWF was embeded in wmode transparent. Also there was JavaScript interaction. The only way was to solve this problem was remove transparent wmode.

           

          >> Is there some esoteric Flex-message-pumping rule

          >> I'm unaware of here that's preventing my text control

          >> from being redrawn in some instances?

           

          No.

           

          >> And if not, is there a way to force a text control to redraw itself?

           

          myControl.invalidateProperties();
          myControl.validateNow();
          

          1 person found this helpful
          • 2. Re: Redraw / message-pump issues
            Level 1

            Thanks for the info on invalidateNow().  I'll try that.  When you say "there was JavaScript interaction" in your app -- do you mean that Flex was calling into Javascript, or vice-versa?

             

            I think you must have misunderstood my question about message-pumping.  What I meant is that it seems ~98% probable that the UI isn't redrawing because the Flex UI thread is being held up by something.

             

            So what doesn't make sense to me is: the window will redraw if I call "confirm()" after invalidating the window, but not if I call setTimeout().  Does calling setTimeout() in JavaScript allow enqueued window messages to be processed in the hosted Flex application?

             

            Or for that matter, does anyone know if Flex runs in the same thread as the Javascript that launches/calls it, or does it run in a different thread/process?

            • 3. Re: Redraw / message-pump issues
              ergo_eleven Level 1

              1. SWF application runs in AVM. JavaScript runs inside browser. This is the absolutely diferent and aparent proceses.

              2. When SWF application calls JavaScript it waits for result and hanging up until JavaScript release it.