【问题标题】:How can I make Flex Busy Indicator load early?如何让 Flex Busy Indicator 提前加载?
【发布时间】:2014-07-11 22:02:58
【问题描述】:

我正在使用 Flash Builder 4.6 和 AIR 构建一个移动应用程序。

我的 Main.mxml 类——一个 ViewNavigatorApplication——引用了一个设置为最少 6 秒时间的启动屏幕。启动画面消失后,有几秒钟的时间,屏幕的内容区域只是空白的白色——这就是我需要出现忙碌指示器的时候。

编辑:根据要求附加代码:

在 Main.mxml 类中:

 protected function viewnavigatorAppInitializeHandler(event:FlexEvent):void
 {
    //checks various criteria to determine which data to load, ie which service call 
    // to make. When that is determined, code calls setUpModel().
 }

 private function setUpModel():void {   
    Model.Instance.initialize(); //adds listeners in the model, 
    //makes service call. Data is returned and parsed in the event handler.
    //APPLICATION_MODEL_LOADED event is then dispatched, and handled here

    Model.Instance.addEventListener( Model.APPLICATION_MODEL_LOADED, modelReadyHandler );
        }

        private function modelReadyHandler(e:Event):void
        {       
            //Busy Indicator only appears *after* the HomeListView is loaded.
            //I need it to appear *while* these calls are being made.
            navigator.pushView(HomeListView); //this is my First View
        }

所以我认为问题是:在 HomeListView 之前显示的是什么?如果是 Main.mxml——ViewNavigatorApplication——那么我该如何避免“不可分配”错误?

在 HomeListView 中:

        [Bindable] private var categoryList:ArrayCollection = new ArrayCollection();
        private function viewActivateHandler():void
        {
            //the service call has been made, and data is ready to be loaded into the control
            categories = Model.Instance.Categories;

我在 HomeListView 中试过这个:

<s:Group width="100%" height="100%">
<s:BusyIndicator 
    id="busy"
    visible="true" symbolColor="blue"
    horizontalCenter="0" verticalCenter="0"
    rotationInterval="100" />
</s:Group>

它有效。但问题是它只在 HomeListView 加载后出现。我认为空白的白色 HomeListView,就在列表出现之前。但事实并非如此。

然后我尝试将上述代码放入 Main.mxml 文件中。但我收到以下错误:

 'spark.components.Group' is not assignable to the default property, 'navigationStack', of type 'spark.components.supportClasses.NavigationStack'.

那么我可以把这个 BusyIndi​​cator 放在哪里,以便它在 HomeListView 出现之前覆盖空白区域?

【问题讨论】:

标签: actionscript-3 apache-flex air flash-builder


【解决方案1】:

我想出了一个办法。

来自documentation

“与 Application 不同,ViewNavigatorApplication 并不意味着接受 UIComponent 对象作为子对象。相反,所有可视组件都应该是应用程序管理的视图的子对象。”

这就是我收到错误的原因。因此,对于我的第一个视图,我创建了一个名为 HolderView 的简单视图,其中包含 BusyIndi​​cator:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" title="HolderView">
<s:Group  width="100%" height="100%">
    <s:BusyIndicator 
        id="busy"
        visible="true" symbolColor="blue"
        horizontalCenter="0" verticalCenter="0"
        rotationInterval="100" />
</s:Group>

然后,从我的 Main.mxml 文件中,我首先加载该 HolderView。

        private function setUpModel():void {    
            Model.Instance.initialize();
            navigator.pushView(HolderView);
            Model.Instance.addEventListener(Model.APPLICATION_MODEL_LOADED, modelReadyHandler );
        }

一旦数据返回——在 Model.APPLICATION_MODEL_LOADED 事件监听器上——我将加载 HomeListView:

        private function modelReadyHandler(e:Event):void
        {       
            navigator.pushView(HomeListView);
        }

这行得通。希望它可以帮助有同样问题的人!

【讨论】:

    猜你喜欢
    • 2011-10-07
    • 2023-03-21
    • 2016-09-16
    • 1970-01-01
    • 2011-02-13
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多