您的位置:首页 > 编程语言 > Java开发

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. 下面是例子代码

 

<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>

 

这两个库都还有其他很多功能,有兴趣可以深入研究
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: