Eclipse 工作台基本概念>视图概述
2011-09-22 11:38
309 查看
要延迟(delay)执行Flex的function,或按顺序同步执行Flex的某些function,可以使用下面两个库
KitchenSync http://code.google.com/p/kitchensynclib/
CASALib http://casalib.org/
1.使用KitchenSync
KitchenSync并没有正式支持Flex,但没有正式支持并不代表不能使用。使用KitchenSync必须先初始化 "KitchenSync.initialize(this);" 而这个方法必须在Application的addedToStage中调用,如果在creationComplete中调用会收到一个Error: frameRateSeed must be a DisplayObject that is part of the Display List. 下面是例子代码
2.使用CASALib
CASALib不用初始化,它的Sequence相对简单些,可以在Sequence中加入多个Function
这两个库都还有其他很多功能,有兴趣可以深入研究
KitchenSync http://code.google.com/p/kitchensynclib/
CASALib http://casalib.org/
1.使用KitchenSync
KitchenSync并没有正式支持Flex,但没有正式支持并不代表不能使用。使用KitchenSync必须先初始化 "KitchenSync.initialize(this);" 而这个方法必须在Application的addedToStage中调用,如果在creationComplete中调用会收到一个Error: frameRateSeed must be a DisplayObject that is part of the Display List. 下面是例子代码
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="350" height="200" layout="absolute" addedToStage="initKitchenSync(event)"> <mx:Script> [CDATA[ import mx.controls.Alert; import org.as3lib.kitchensync.action.KSFunction; import org.as3lib.kitchensync.KitchenSync; public function initKitchenSync(evnet:Event) : void { KitchenSync.initialize(this); } public function onClickBtn() : void { var alertMsg : String = "delay " + timeInput.value + " millisecond"; var delayFunction : KSFunction = new KSFunction(timeInput.value, showAlert, alertMsg); delayFunction.start(); } public function showAlert(message : String) : void { Alert.show(message); } ]] </mx:Script> <mx:ApplicationControlBar x="10" y="10" fillAlphas="[1.0, 1.0]" fillColors="[#D3FED3, #ADC3AD]"> <mx:Label text="Delay"/> <mx:NumericStepper id="timeInput" minimum="10" maximum="20000" enabled="true" stepSize="200" width="89" value="1000"/> <mx:Label text="millisecond"/> <mx:Button label="Show Alert" click="onClickBtn()"/> </mx:ApplicationControlBar> </mx:Application>
2.使用CASALib
CASALib不用初始化,它的Sequence相对简单些,可以在Sequence中加入多个Function
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="350" height="200" layout="absolute"> <mx:Script> [CDATA[ import mx.controls.Alert; import org.casalib.time.Sequence; public function onClickBtn() : void { var functionSequence : Sequence = new Sequence(false); functionSequence.addTask(showAlert, timeInput.value); //functionSequence.addTask(otherMethod, timeInput.value); functionSequence.start(); } public function showAlert() : void { Alert.show("delay " + timeInput.value + " millisecond"); } ]] </mx:Script> <mx:ApplicationControlBar x="10" y="10" fillAlphas="[1.0, 1.0]" fillColors="[#D3FED3, #ADC3AD]"> <mx:Label text="Delay"/> <mx:NumericStepper id="timeInput" minimum="10" maximum="20000" enabled="true" stepSize="200" width="89" value="1000"/> <mx:Label text="millisecond"/> <mx:Button label="Show Alert" click="onClickBtn()"/> </mx:ApplicationControlBar> </mx:Application>
这两个库都还有其他很多功能,有兴趣可以深入研究
相关文章推荐
- Eclipse 工作台基本概念>帮助视图
- Eclipse 工作台基本概念>提纲视图
- Eclipse 工作台基本概念>属性视图
- Eclipse 工作台基本概念>任务视图
- Eclipse 工作台基本概念>快速视图
- Eclipse 工作台基本概念>项目浏览器视图
- Eclipse 工作台基本概念>问题视图
- Eclipse 工作台基本概念>搜索视图
- Eclipse 工作台基本概念>分离视图
- Eclipse 工作台基本概念>工具栏
- Eclipse 工作台基本概念>资源
- Eclipse 工作台基本概念>路径变量
- Eclipse 工作台基本概念>编辑器
- Eclipse 工作台基本概念>构建
- Eclipse 工作台基本概念>欢迎页面
- Eclipse 工作台基本概念>资源层次
- Eclipse 工作台基本概念>标记
- Eclipse 工作台基本概念>资源过滤器
- Eclipse 工作台基本概念>本地历史
- Eclipse 工作台基本概念>工作集