views:

3442

answers:

4

Whenever I set a indeterminate progress bar in a modal pop-up via PopUpManager, there is no progress displayed. If I add the same ProgressBar to the parent regularly or make the pop-up non-modal it works. Is there a reason why it doesn't work in modal pop-ups? and a way to make it work?

Thanks.

+1  A: 

I have had some other developers look at this, it turns out it is a bug, but there is a work around..I'll post my original code and then the altered code for the work around:

original:

private function showLoading(e:Event = null):void
      {
       if(_progBar == null)
       {
        _progBar = new ProgressBar();
        _progBar.width = 200;
        _progBar.indeterminate = true;
        _progBar.labelPlacement = 'center';
        _progBar.setStyle("removedEffect", fade);
        _progBar.setStyle("addedEffect", fade);
        _progBar.setStyle("color", 0xFFFFFF);
        _progBar.setStyle("borderColor", 0x000000);
        _progBar.setStyle("barColor", 0xf4b60f);
        _progBar.label = "";
       }
       PopUpManager.addPopUp(_progBar,this,true);
       PopUpManager.centerPopUp(_progBar);
      }

work around:

private function showLoading(e:Event = null):void
      {
       if(_progBar == null)
       {
        _progBar = new ProgressBar();
        _progBar.width = 200;
        _progBar.indeterminate = true;
        _progBar.labelPlacement = 'center';
        _progBar.setStyle("removedEffect", fade);
        _progBar.setStyle("addedEffect", fade);
        _progBar.setStyle("color", 0xFFFFFF);
        _progBar.setStyle("borderColor", 0x000000);
        _progBar.setStyle("barColor", 0xf4b60f);
        _progBar.label = "";
        _progBar.mode = ProgressBarMode.MANUAL;
       }
       PopUpManager.addPopUp(_progBar,this,true);
       PopUpManager.centerPopUp(_progBar);
        _progBar.setProgress(0, 0);
      }
John Isaacks
A: 

Hi..We can do this by using containter.addChild(Pg) eg.Canvas and then use PopUpManager.

shailendra
A: 

I had the same problem, but neither of the other solutions helped. Below is the code that produces the problem for me:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="applicationComplete();">
    <mx:Script><![CDATA[
        import mx.controls.ProgressBar;
        import mx.managers.PopUpManager;
        private function applicationComplete():void
        {
            var progressBar:ProgressBar = new ProgressBar()
            progressBar.indeterminate = true;
            PopUpManager.addPopUp(progressBar, this, true);
            //this.addChild(progressBar);           including this line overrides the popup
            //progressBar.setProgress(0, 0);        including this line makes no difference
        }
    ]]></mx:Script>
    <mx:Label text="hello"/>
</mx:Application>

The two commented out lines are what I understood to be the other suggested solutions. I managed to fix this using the awkward workaround below:

Step 1: Create custom mxml component, saved as Progress.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
    <mx:ProgressBar indeterminate="true" />
</mx:TitleWindow>

Step 2: Use custom component in code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="applicationComplete();">
    <mx:Script><![CDATA[
        import mx.controls.ProgressBar;
        import mx.managers.PopUpManager;
        import Progress;
        private function applicationComplete():void
        {
            var progress:Progress =  new Progress();
            PopUpManager.addPopUp(progress, this, true);
            PopUpManager.centerPopUp(progress);
        }
    ]]></mx:Script>
    <mx:Label text="hello"/>
</mx:Application>

It seems that putting the ProgressBar inside the TitleWindow is important.

mauvo
A: 

It worked for me once I put the ProgressBar inside a TitleWindow. For instance, this was not working:

var waitingpopup:ProgressBar = new ProgressBar();
waitingpopup.indeterminate = true;
waitingpopup.label = "Please wait, loading...";    
PopUpManager.addPopUp(waitingpopup, this, true);

And this worked

var waitingpopup:TitleWindow = new TitleWindow();
waitingpopup.title = "Please Wait";
var pb:ProgressBar = new ProgressBar();
pb.indeterminate = true;
pb.label = "Loading...";
waitingpopup.addChild(pb);    
PopUpManager.addPopUp(waitingpopup, this, true);
Joshua Beall