2009-04-22 59 views
1

每當我通過PopUpManager在模態彈出框中設置不確定的進度條時,不會顯示進度。如果我經常向父節點添加相同的ProgressBar,或者使彈出的非模態工作。是否有一個原因,它不適用於模態彈出窗口?並使其工作的一種方式?Flex:不確定ProgressBar在模態彈出?

謝謝。

+0

奇怪 - 你能發佈一些代碼,也許?可能更容易說出發生了什麼事情。 – 2009-04-22 21:03:52

回答

1

我有一些其他的開發者看看這個,事實證明這是一個錯誤,但對於工作圍繞工作around..I'll發佈我的原代碼,然後改變代碼:

原:

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

我們可以通過使用containter.addChild(PG)eg.Canvas做到這一點,然後使用PopUpManager中。

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中很重要。

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