ViewNavigator 基本上用于在不同的视图中导航,但是有没有更简单的方法来限制切换到任何视图并执行一些操作呢?
例如:我正在查看产品手册或帮助文档,并且没有进入任何视图,我想通过单击 viewnavigator 中的按钮来致电客户服务中心
代码
<s:ViewNavigator id="navigatorHome" width="100%" height="100%"
elementAdd="viewAdded(event)" elementRemove="viewRemoved(event)"
icon="{Images.iconHome64}" firstView="{HomeView}">
<s:navigationContent>
<s:Button icon="{iconBack}" click="{navigatorHome.activeView.navigator.popView()}"/>
</s:navigationContent>
</s:ViewNavigator>
<s:ViewNavigator id="navigatorPhone" width="100%" height="100%"
elementAdd="viewAdded(event)" elementRemove="viewRemoved(event)"
icon="{iconPhone}" >
</s:ViewNavigator>
<s:ViewNavigator id="navigatorAlert" width="100%" height="100%"
elementAdd="viewAdded(event)" elementRemove="viewRemoved(event)"
icon="{iconAlerts}" firstView="{AlertView}">
</s:ViewNavigator>
<s:ViewNavigator id="navigatorSettings" width="100%" height="100%"
elementAdd="viewAdded(event)" elementRemove="viewRemoved(event)"
icon="{iconSettings}" firstView="{SettingsView}">
<s:navigationContent>
<s:Button icon="{iconBack}" click="{navigatorSettings.activeView.navigator.popView()}"/>
</s:navigationContent>
</s:ViewNavigator>
所以这里navigatorPhone
不应该打开任何视图,而是调用一些函数,有没有办法?
更新
我在这里看到有一个Removing event
所以我得到了这个
private function removing(event:ViewNavigatorEvent):void
{
trace("Inside removing event: "+event.currentTarget.name+", "+communicateViewCalled+", "+navigatorHome.activeView.name);
//event.preventDefault();
}
所以在这里,如果我知道点击的视图,它会成功的。有什么帮助吗?
默认情况下跟踪输出我打开HomeView
并单击CommunicateView
内部删除事件:HomeView, false, HomeView