我正在 flex 中开发一个桌面应用程序,其中我有 2 个屏幕(即 mxml 窗口应用程序).我想从一个屏幕导航到另一个屏幕(从 mxml 文件到另一个).我该怎么做?
很多方法,但我可能会使用其中一种:
- 您可以使用状态更改屏幕
- 您可以使用 ViewStack 或其他导航器。
您可以在桌面应用程序中使用ViewNavigator,只需要做一些技巧
-
添加到项目舞台方向事件类
包闪存事件{
public class StageOrientationEvent extends Event { static public const ORIENTATION_CHANGE:String = "orientationChange"; static public const ORIENTATION_CHANGING:String = "orientationChanging"; public function StageOrientationEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) { super(type, bubbles, cancelable); } }
}
-
为 ViewNavigator 创建新皮肤
<s:皮肤>
<fx:Metadata>[HostComponent("spark.components.ViewNavigator")]</fx:Metadata> <fx:Script fb:purpose="styling"> <![CDATA[ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number) : void { super.updateDisplayList(unscaledWidth, unscaledHeight); } ]]> </fx:Script> <s:states> <s:State name="normal" /> <s:State name="disabled" /> <s:State name="landscape" /> <s:State name="portrait" /> <s:State name="landscapeAndOverlay" /> <s:State name="portraitAndOverlay" /> </s:states> <s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" minWidth="0" minHeight="0"> <s:layout> <s:BasicLayout/> </s:layout> </s:Group>
-
将mobilecomponents.swc添加到您的项目中(您可以在flex sdk文件夹中找到它,在我的例子中,路径是C:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\frameworks\libs\mobile\mobilecomponents.swc)
-
将新的视图导航器外观(步骤 2)分配给视图导航器
直接到 ViewNavigator 实例:
<s:ViewNavigator skinClass="path.to.skin.ViewNavigatorSkin"/>
或在 CSS 中全局
s|ViewNavigator{
skinClass: ClassReference("path.to.skin.ViewNavigatorSkin");
}