- 浏览: 253584 次
- 性别:
- 来自: 厦门
-
文章分类
最新评论
-
topbox163:
图片显示不了
Flex 学习曲线图 -
彭利贤:
你好,想请教您一些关于flash的问题,您可以加我qq吗 59 ...
全屏flash的尺寸分析 -
jingj6:
是开源的吗?
小日本做的非常强大的一款AS3 3D引擎 -
hugh52066:
LZ牛B。
Flex 学习曲线图 -
sweed0:
a dream~~
一个让人瞠目结舌的传奇电脑高手!
一、概述
二、LIB库包配置
- 下载需要的LIB库
- Spring AS 依赖包
as3commons-bytecode-0.7.swc、as3commons-lang-0.3.swc、as3commons-logging-1.2.swc、as3commons-reflect-1.3.1.swc - Spring AS:
核心库:spring-actionscript-core-1.1.swc、针对于cairngorm3的库 spring-actionscript-cairngorm-1.1.swc - 导航库LIB库:
navigationSpringAS-1.7.swc
- Spring AS 依赖包
- 设置编译属性
打开工程属性选择 Flex 编译器选项卡,在“附加的编译器参数”添加“ -include-libraries flex_libs/as3commons-reflect-1.3.1.swc flex_libs/as3commons-lang-0.3.swc flex_libs/as3commons-logging-1.2.swc ”。将依赖包添加到编译器里面编译,这样在启动时才能使用Spring AS。
三、定义导航点 ContentDestination
package cn.com.enboga.scdemo.core.application { public class ContentDestination { public static const LOGIN:String = "content.login"; public static const MAIN:String = "content.main"; public static const MAIN_TRUE:String = "content.main.true"; public static const MAIN_FALSE:String = "content.main.false"; } }
四、设置导航器,并设置导航点
在导航器里面需要定义元数据[Waypoint]设置为导航器,然后设置每个导航点的automationName为上面定义的导航点名称。这样导航点时候可以根据这个名字导航到这个导航点上。
<?xml version="1.0" encoding="utf-8"?> <mx:ViewStack xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" xmlns:main="cn.com.enboga.scdemo.core.presentation.main.*" xmlns:login="cn.com.enboga.scdemo.core.presentation.login.*"> <fx:Metadata> [Waypoint] </fx:Metadata> <fx:Script> <![CDATA[ import cn.com.enboga.scdemo.core.application.ContentDestination; ]]> </fx:Script> <s:NavigatorContent width="100%" height="100%" automationName="{ ContentDestination.LOGIN }"> <login:UILoginGroup /> </s:NavigatorContent> <s:NavigatorContent width="100%" height="100%" automationName="{ ContentDestination.MAIN }"> <main:UIMainGroup /> </s:NavigatorContent> </mx:ViewStack>
五、接下来为导航器定义一个PM
navigateTo 方法传入导航点名称,就可以导航定位到该导航点
package cn.com.enboga.scdemo.core.presentation { import com.adobe.cairngorm.LogUtil; import com.adobe.cairngorm.navigation.NavigationEvent; import com.adobe.cairngorm.navigation.state.ISelectedIndex; import mx.logging.ILogger; import org.springextensions.actionscript.core.event.EventBus; [Landmark(name="content")] public class ContentPM implements ISelectedIndex { private static const LOG:ILogger = LogUtil.getLogger(ContentPM); [Bindable] /** 导航索引 */ public var selectedIndex:int; [Enter(time="first")] public function firstEnter():void { LOG.info("content:FirstEnter"); } [Enter(time="next")] public function enter():void { LOG.info("content:Enter"); } [Exit] public function exit():void { LOG.info("content:Exit"); } /** 导航到destination */ public function navigateTo(destination:String):void { EventBus.dispatchEvent(NavigationEvent.createNavigateToEvent(destination)); } /** 导航到destination */ public function navigateAway(destination:String):void { EventBus.dispatchEvent(NavigationEvent.createNavigateAwayEvent(destination)); } } }
六、将导航器组件加入到Spring AS 配置文件
- 定义配置文件
<?xml version="1.0" encoding="utf-8"?> <Objects xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="http://www.springactionscript.org/mxml/config" xmlns:application="cn.com.enboga.scdemo.core.application.*" xmlns:presentation="cn.com.enboga.scdemo.core.presentation.*" xmlns:stage="org.springextensions.actionscript.stage.*" xmlns:config="org.springextensions.actionscript.ioc.factory.config.*" xmlns:cairngorm="http://ns.adobe.com/cairngorm" xmlns:main="cn.com.enboga.scdemo.core.presentation.main.*" xmlns:login="cn.com.enboga.scdemo.core.presentation.login.*"> <!-- Presentation --> <presentation:ContentPM /> <!-- Application --> <!-- Infrastructure --> <!--Spring AS specific initializations--> <stage:DefaultAutowiringStageProcessor/> <config:EventHandlerMetadataProcessor/> <cairngorm:NavigationAdaptor/> <cairngorm:FirstEnterProcessor/> <cairngorm:EveryEnterProcessor/> <cairngorm:NextEnterProcessor/> <cairngorm:ExitProcessor/> <cairngorm:LandmarkProcessor/> <cairngorm:WaypointProcessor/> <cairngorm:WaypointHistory id="contentHistory"> <mx:String>content</mx:String> </cairngorm:WaypointHistory> <cairngorm:GlobalHistory id="globalHistory"/> </Objects>
- 加载配置文件,这里是使用的是MXML的加载模式,也可以使用配置文件的加载模式。
同时把导航器放入主容器里面。<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:cairngorm="com.adobe.cairngorm.*" minWidth="955" minHeight="600" creationComplete="creationCompleteHandler()" xmlns:presentation="cn.com.enboga.scdemo.core.presentation.*"> <fx:Script> <![CDATA[ import cn.com.enboga.scdemo.ContentContext; import cn.com.enboga.scdemo.core.presentation.UIContentViewStack; import mx.controls.Alert; import mx.events.FlexEvent; import mx.logging.LogEventLevel; import org.springextensions.actionscript.context.support.FlexXMLApplicationContext; import org.springextensions.actionscript.context.support.MXMLApplicationContext; /** Spring 上下文 */ private var _appContext:FlexXMLApplicationContext = new FlexXMLApplicationContext(); private var appContext:MXMLApplicationContext; /** 初始化 */ protected function creationCompleteHandler():void { // _appContext = new FlexXMLApplicationContext(); // _appContext.addConfigLocation("config/application-context.xml"); // _appContext.addEventListener(Event.COMPLETE, applicationContext_completeHandler); // _appContext.addEventListener(IOErrorEvent.IO_ERROR, applicationContext_ioErrorHandler); // _appContext.load(); appContext = new MXMLApplicationContext(ContentContext); appContext.load(); } /** Spring 配置文件初始化完成后执行 */ private function applicationContext_completeHandler(event:Event):void { this.addElement(new UIContentViewStack()); } /** Spring 配置文件初始化错误 */ private function applicationContext_ioErrorHandler(event:IOErrorEvent):void { Alert.show("读取StringAS配置文件出错!", "错误"); } ]]> </fx:Script> <fx:Declarations> <!-- 定义日志 --> <mx:TraceTarget level="{ LogEventLevel.ALL }" includeCategory="true"> <mx:filters> <fx:Array> <fx:String>com.adobe.cairngorm.*</fx:String> <fx:String>cn.com.enboga.scdemo.*</fx:String> </fx:Array> </mx:filters> </mx:TraceTarget> </fx:Declarations> <presentation:UIContentViewStack /> </s:Application>
七、在导航点里面导航到其他导航点
- UILoginGroup.mxml
<?xml version="1.0" encoding="utf-8"?> <s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"> <fx:Script> <![CDATA[ import cn.com.enboga.scdemo.core.application.ContentDestination; import cn.com.enboga.scdemo.core.presentation.ContentPM; [Bindable] [Autowired] public var contentPM:ContentPM; ]]> </fx:Script> <s:Button label="首页" click="contentPM.navigateTo(ContentDestination.MAIN)" /> <s:Button label="true" click="contentPM.navigateTo(ContentDestination.MAIN_TRUE)" /> <s:Button label="false" click="contentPM.navigateTo(ContentDestination.MAIN_FALSE)" /> </s:VGroup>
- UIMainGroup.mxml
<?xml version="1.0" encoding="utf-8"?> <s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" xmlns:main="cn.com.enboga.scdemo.core.presentation.main.*"> <fx:Script> <![CDATA[ import cn.com.enboga.scdemo.core.application.ContentDestination; import cn.com.enboga.scdemo.core.presentation.ContentPM; [Bindable] [Autowired] public var contentPM:ContentPM; ]]> </fx:Script> <s:Button label="返回登录" click="contentPM.navigateTo(ContentDestination.LOGIN)" /> <s:Button label="true" click="contentPM.navigateTo(ContentDestination.MAIN_TRUE)" /> <s:Button label="false" click="contentPM.navigateTo(ContentDestination.MAIN_FALSE)" /> <main:UIMainViewStack /> </s:VGroup>
- UIMainViewStack.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:ViewStack xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"> <fx:Metadata> [Waypoint] </fx:Metadata> <fx:Script> <![CDATA[ import cn.com.enboga.scdemo.core.application.ContentDestination; ]]> </fx:Script> <s:NavigatorContent width="100%" height="100%" automationName="{ ContentDestination.MAIN_TRUE }"> <s:Label text="MAIN_TRUE" /> </s:NavigatorContent> <s:NavigatorContent width="100%" height="100%" automationName="{ ContentDestination.MAIN_FALSE }"> <s:Label text="MAIN_FALSE" /> </s:NavigatorContent> </mx:ViewStack>
发表评论
-
Flex4学习笔记-命名空间
2010-05-11 23:17 4443<?xml version="1.0&qu ... -
将Flex 3 应用程序迁移到 Flex 4
2010-05-05 22:59 3589http://www.adobe.com/cn/devnet/ ... -
Adobe Flash Builder 4 Premium最终版高速下载
2010-05-05 22:18 3812简介 欢迎下载Adobe Flash Builder 4 P ... -
在Flex Builder 3里安装Flex4 SDK,开始Flex4之旅
2010-05-02 22:36 3231http://www.puxiao.com/?p=276 ... -
“Flex 4 SDK 新特性”讲稿和Demo源代码
2010-05-02 18:25 1765PDF在线查看地址:https://acrobat.co ... -
Flash Builder 4beta2 版中的新特性
2009-11-19 15:15 1625这是一篇来自Adobe开发者中心的文章,由RIAMeeti ... -
Mate框架应该成为Flex4的新标准吗?
2009-09-15 10:58 2691Flex开发领域有许 ... -
浅析Mate flex framework在实际项目中的应用(三)
2009-09-14 14:06 1589经过上两篇文章的洗礼,相信大家对mate flex frame ... -
浅析Mate flex framework在实际项目中的应用(二)
2009-09-14 13:58 1867本篇文章是结合实际的flex project来分别的说一下这个 ... -
浅析Mate flex framework在实际项目中的应用(一)
2009-09-14 13:24 1832做项目也有很长时间了,也用过很多的framework:Cair ... -
Flex学习笔记_06 使用行为对象和动画效果_ 放缩\调整大小效果
2008-09-28 16:47 38426.3.2 放缩效果和调整大 ... -
Flex学习笔记_06 使用行为对象和动画效果_模糊、发光效果
2008-09-27 22:33 31876.3.1 模糊效果和发光效 ... -
众说纷纭的Flex框架Mate
2008-09-23 17:04 1201原翻译地址: http://www.infoq.com/cn ... -
Flex学习笔记_06 使用行为对象和动画效果_认识行为对象、行为和组件
2008-08-17 01:30 22436.1 认识行为对象 6.1.1 什么是行为对象 行 ... -
使用BlazeDS和AMF构建Web和桌面应用
2008-08-05 09:29 3079作者 James Ward and Shasha ... -
Flex学习笔记_09 数据绑定_运用实例
2008-07-28 23:41 32519.3.1 实现界面的多语言切换 <?xml vers ... -
Flex学习笔记_09 数据绑定_晋级篇
2008-07-28 22:27 28899.2.1 函数和类级别的绑 ... -
Flex学习笔记_09 数据绑定_概念、使用
2008-07-21 23:32 20869.1 认识数据绑定 9.1.1 数据绑定的概念 ... -
Flex学习笔记_08 Flex的事件机制_高级应用
2008-07-16 23:11 32128.3 事件机制的高级应用 8.3.1 事件的优先级别和 ... -
Flex框架Mate的Alpha版闪亮登场
2008-07-15 19:01 1435作者 Moxie Zhan ...
相关推荐
ActionScript是Flex的主要编程语言,尤其是其第三版本AS3,提供了面向对象的特性,支持事件处理、网络通信、多媒体操作等功能。这部分将深入讲解AS3的基础知识,包括变量、数据类型、控制结构、函数、类和对象等,是...
- **面向对象编程**:学习如何在AS3中实现面向对象编程,包括类、接口、继承和多态性。 - **事件处理**:理解Flex中的事件模型,学习如何处理用户交互事件。 #### 6. Demo1: 开始 - **项目搭建**:创建一个新的Flex...
- 例如,可以使用 `mx.controls.Navigator` 或其他第三方库来实现页面之间的导航。 - 正确地管理页面跳转对于创建流畅的用户体验非常重要。 ### 10. 样式与主题 - **样式和主题** 是用来定义 Flex 应用程序外观的...
- **变量与数据类型**:掌握AS3中的基本数据类型,如int、Number、String等。 - **控制结构**:学习条件语句(if/else)、循环语句(for/while)等。 - **函数与对象**:理解函数的定义与调用、类与对象的概念。 ##...
掌握AS3是深入学习Flex的关键。教程中会涵盖变量、函数、类等基本概念。 #### 6. 数据类型 - **数据管理**:数据类型是编程的基础之一。Flex支持多种数据类型,包括基本类型(如字符串、数字)和复合类型(如数组...