我正在使用Flash Builder 4.6和AIR构建移动应用。
My 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 - 那我该如何避免'not assignable'错误?
在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'.
那么在HomeListView出现之前,我可以在哪里放置这个BusyIndicator以覆盖空白区域?
答案 0 :(得分:0)
我已经想出办法来做到这一点。
&#34;与Application不同,ViewNavigatorApplication并不意味着接受UIComponent对象作为子对象。相反,所有可视组件都应该是应用程序管理的视图的子组件。&#34;
这就是我收到错误的原因。因此,对于我的第一个View,我创建了一个名为HolderView的简单视图,其中包含BusyIndicator:
<?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);
}
这很有效。希望它可以帮助有同样问题的人!