Search code examples
actionscript-3apache-flexactionscriptflex4.5

Flex PopUpManager Modality Issue


I have a spark window container which has a list of files that are downloadable, on clicking a file the file is getting downloaded using the URLStream method and using the ProgressEvent method to track the % of file downloaded as :

stream.addEventListener(ProgressEvent.PROGRESS, progressHandler);

Now in the progressHandler method, I am calling the preogressBar in a titleWindow using popUpManager as :

public function progressHandler(event:ProgressEvent):void
            {           
                tWin.title = "Please Wait";
                tWin.width=400;
                tWin.height=100;
                pb.width=300;
                pb.height=30;
                pb.labelPlacement="center";
                pb.label = "Downloading " + Math.round(event.bytesLoaded / event.bytesTotal * 100).toString() + "%";
                pb.setProgress(event.bytesLoaded, event.bytesTotal);
                tWin.addChild(pb);
                PopUpManager.addPopUp(tWin, this, true);
                PopUpManager.bringToFront(tWin);
                PopUpManager.centerPopUp(tWin);
            }

Here tWin and pb are titleWindow and ProgressBar respectively which I have defined globally above.

Also at the completin=on of the event, I am calling another function to remove the popUpManager as :

public function completeHandler(event:Event):void{
                PopUpManager.removePopUp(tWin);
                             }

Now when I execute the code,the progressBar pop's up and shows the progress and makes the original window modal as I have turned the modality to TRUE in addPopUp function and after the download finishes, the popup is removed but the modality of the window remains as it is i.e. the window is not clickable.

Also if I turn the modality to FALSE in addPopUp function then the progressbar doesnot show up above the window, instead it is somewhere behind the original window and cannot be seen.(I only see a part of it)

Can anybody help with how can I resolve this error of displaying back the original window once the pop-up is removed.


Solution

  • Progress event should not be adding the pop up

        stream.addEventListener(ProgressEvent.PROGRESS, progressHandler);
        stream.addEventListener(Event.OPEN, initProgress);
    
    
    
    
        public function progressHandler(event:ProgressEvent):void
            {     
                pb.width=300;
                pb.height=30;
                pb.labelPlacement="center";
                pb.label = "Downloading " + Math.round(event.bytesLoaded / event.bytesTotal * 100).toString() + "%";
                pb.setProgress(event.bytesLoaded, event.bytesTotal);  
            }
    
        public function initProgress(event:Event):void
            {
                tWin.title = "Please Wait";
                tWin.width=400;
                tWin.height=100;
                tWin.addChild(pb);
                PopUpManager.addPopUp(tWin, this, true);
                PopUpManager.bringToFront(tWin);
                PopUpManager.centerPopUp(tWin);
            }