我正在开发一个 flex 桌面应用程序,其中我有 2 个屏幕(即 mxml 窗口应用程序)。我想从一个屏幕导航到另一个屏幕(从 mxml 文件到另一个)。我该怎么做?
2 回答
您可以在桌面应用程序中使用 ViewNavigator,只需要做一些技巧
添加到您的项目 StageOrientationEvent 类
包 flash.events {
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:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled="0.5" >
<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>
< /s:Skin>
Add mobilecomponents.swc to your project (you can find it in flex sdk folder, in my case path is C:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\frameworks\libs\mobile\mobilecomponents.swc)
assign your new ViewNavigator skin (step 2) to ViewNavigator
direct to ViewNavigator instance:
<s:ViewNavigator skinClass="path.to.skin.ViewNavigatorSkin"/>
or globally in css
s|ViewNavigator{
skinClass: ClassReference("path.to.skin.ViewNavigatorSkin");
}