1

每当我通过 PopUpManager 在模式弹出窗口中设置不确定的进度条时,都不会显示进度。如果我定期将相同的 ProgressBar 添加到父级或使弹出窗口非模态它可以工作。为什么它在模态弹出窗口中不起作用是有原因的吗?以及让它发挥作用的方法?

谢谢。

4

4 回答 4

1

我让其他一些开发人员看过这个,结果证明这是一个错误,但有一个变通方法..我将发布我的原始代码,然后为变通方法发布更改的代码:

原来的:

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);
            }

解决方法:

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);
            }
于 2009-04-23T13:25:20.990 回答
0

我们可以通过使用containter.addChild(Pg) eg.Canvas 来做到这一点,然后使用PopUpManager。

于 2010-01-28T08:59:17.803 回答
0

我遇到了同样的问题,但其他解决方案都没有帮助。以下是为我产生问题的代码:

<?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>

这两条注释掉的行是我理解的其他建议的解决方案。我设法使用以下尴尬的解决方法解决了这个问题:

步骤 1:创建自定义 mxml 组件,保存为 Progress.mxml

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

第 2 步:在代码中使用自定义组件

<?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>

似乎将 ProgressBar 放在 TitleWindow 内很重要。

于 2010-02-24T22:11:47.080 回答
0

一旦我将 ProgressBar 放在 TitleWindow 中,它就对我有用。例如,这不起作用:

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

这有效

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);
于 2010-09-17T14:07:47.133 回答