当应用程序繁忙时,我们如何在flex中实现“Please wait ....”屏幕

时间:2010-03-16 10:21:15

标签: flex

我有一个功能可以恢复我的应用程序的所有默认设置。这个过程可能需要一些时间,因此我想实现一个“请等待...”模式弹出窗口,让用户知道一切正常,程序没有冻结。一旦该函数完成其任务,我希望它删除该消息,并恢复正常行为。

alt text http://www.freeimagehosting.net/uploads/c5906da30c.jpg

4 个答案:

答案 0 :(得分:2)

开始时:

var waitingpopup:TitleWindow = new TitleWindow()
waitingpopup.title = "Please Wait ..."

PopupManager.addPopup(waitingpopup, this, true)

完成后:

PopupManager.removePopup(waitingpopup)

答案 1 :(得分:1)

您可以使用PopUpManager创建带有动画微调器的模态弹出窗口。 Alert组件执行此操作。您始终可以参考警报源代码以查看其工作原理。

答案 2 :(得分:1)

只要您不需要向用户传达任何内容而不是“应用程序仍在运行”,我认为更优雅的方法是更改​​光标:

mx.managers.CursorManager.setBusyCursor()
//do stuff
mx.managers.CursorManager.removeBusyCursor()
光标将变为带旋转手的时钟。我不确定是否有办法用自己的动画覆盖它,但它很简单,不需要你设计自己的窗口。

答案 3 :(得分:-1)

对于那些迟到这个问题的人,Adobe在4.5中发布了一个Throbber:

http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1283019

http://fusiongrokker.com/post/using-the-flex-4-5-busyindicator

http://flexdevtips.blogspot.com/2011/05/simple-animating-preloader-and.html

例如,从上面的fusiongrokker链接运行以下命令:

             

        private function busyOn():void
        {
            throbberId.visible = true;
        }

        private function busyOff():void
        {
            throbberId.visible = false;
        }
    ]]>
</fx:Script>

<s:VGroup width="100%" 
          paddingLeft="10" 
          paddingRight="10" 
          paddingTop="10" 
          paddingBottom="10">
    <s:BusyIndicator 
        id="throbberId" 
        visible="false" 
        rotationInterval="{rotationInterval}" />
    <s:Button 
        id="start" 
        click="busyOn()" 
        width="100%" 
        height="50" 
        label="start" />
    <s:Button 
        id="stop" 
        click="busyOff()" 
        width="100%" 
        height="50" 
        label="stop" />
</s:VGroup>