3 Replies Latest reply on Nov 17, 2009 11:22 AM by AndreyG80

    Progress popup window

    AndreyG80

      Hi, All,

       

      I want to show a popup window with indeterminate progress bar while time consuming operation is performed. Time consuming operation is jpeg encoding and network activity with URLLoader. Like this:

       

      private function buttonClickHandler(event: Event): void {

           ...

           progressPopup = ProgressPopup(PopUpManager.createPopUp(this, ProgressPopup, true));

           progressPopup.addEventListener(FlexEvent.CREATION_COMPLETE, doLongOp);

           ...

      }

       

      private function doLongOp(event: Event): void {

           var worker: MyWorker = new MyWorker (...);

           worker.addEventListener(MyWorker.COMPLETE, successHandler);

           worker.addEventListener(MyWorker.ERROR, errorHandler);

           worker.go();

      }

       

      successHandler and errorHandler handlers enable close button on popup and when operation completes (successfully or not) user is able to close popup. What is actually happening is that worker starts BEFORE popup is shown, UI is freezing, I see worker loads CPU (jpeg encoder on a large image) and only after that popup is shown. How should I make popup before worker is actually started, so that popup is shown all the time worker is processing?

       

      Thanks.

        • 1. Re: Progress popup window
          Subeesh Arakkan Level 4

          Hi,

           

          Try with calllLater

           

          callLater(worker.go);

          • 2. Re: Progress popup window
            AndreyG80 Level 1

            This is the simple app which is not working, as I want it to (popup is shown actually AFTER jpeg encoding):

             

            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

                 <mx:Button x="117" y="177" label="Button" click="click(event)"/>

                 <mx:Script>

                      <![CDATA[

                           import mx.managers.CursorManager;

                           import mx.events.FlexEvent;

                           import mx.graphics.codec.JPEGEncoder;

                           import mx.managers.PopUpManager;

             

                          

                           private var _popup: MyPopup;

             

                          

                           private function click(event: Event): void {

                                _popup = MyPopup(PopUpManager.createPopUp(this, MyPopup, true));

                                _popup.addEventListener(FlexEvent.CREATION_COMPLETE, popupCreationHandler);

                                //callLater(longOp); // this calls longOp before popup is shown

                           }

             

             

                           private function longOp(): void {

                                var jpegEncoder: JPEGEncoder = new JPEGEncoder(60);

                                var jpegData: ByteArray = jpegEncoder.encode(Bitmap(image.content).bitmapData);

                           }

             

             

                           private function popupCreationHandler(event: Event): void {

                                callLater(longOp);

                           }

                      ]]>

                  </mx:Script>

                 <mx:Image x="239" y="177" width="100" height="100" id="image">

                      <mx:source>ANY_LARGE_IMAGE.jpg</mx:source>

                  </mx:Image>

            </mx:Application>

            • 3. Re: Progress popup window
              AndreyG80 Level 1

              Subeesh Arakkan wrote:

               

              Hi,

               

              Try with calllLater

               

              callLater(worker.go);

               

              This doesn't help