国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

11.13.動態生成States和Transitions

2024-04-27 13:52:12
字體:
來源:轉載
供稿:網友
11.13.1. 問題
我需要動態生成新的states 和transitions。
11.13.2. 解決辦法
創建新的State 和Transition 對象,添加它們的屬性,把它們添加到每個UIComponent 對象定義的states 和transition 數組中。
11.13.3. 討論
一般情況下是不能頻繁地創建新的states 和transition 的。但是在某些情況下是很有必要的。

比如模板組件。因為每個UIComponent 對象有一個states 數組和transition 數組,包含所有的State 和Transition 對象,創建新的states 和transitions 只需要簡單的定義State 或Transition并添加到對應的數組中即可:
+展開
-ActionScript
var state:State = new State();
var button:Button = new Button();
button.label = "LABEL";
var addChild:AddChild = new AddChild(vbox, button);
state.overrides = [addChild];
state.name = "buttonState";
states.push(state);

這里被重寫的數組是將被使用的State 的重寫列表,就是,哪些功能將被定義,哪些特定的State 屬性將被定義,比如任何SetProperty 或SetStyle 操作,所有為State 定義的重寫都是實現了IOverride 接口,一般包含下列:
AddChild
RemoveChild
SetEventHandler
SetProperty
SetStyle

(For more information on the IOverride interface, see Recipe 11.15.)
下面是完整的代碼,注意創建Transition 對象,添加屬性,指定toState 和fromState 屬性的這些方法:
+展開
-XML
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxmlwidth="400height="300">
<mx:Script>
<![CDATA[
import mx.controls.Button;
import mx.states.AddChild;
import mx.states.State;
import mx.states.Transition;
import mx.effects.Move;
public function addTransitions():void {
var transition:Transition = new Transition();
var move:Move = new Move();
move.duration=400;
move.target = vbox;
transition.fromState = "buttonState";
transition.toState = "*";
transition.effect = move;
transitions.push(transition);
}
public function addState():void {
var state:State = new State();
var button:Button = new Button();
button.label = "LABEL";
var addChild:AddChild = new AddChild(vbox, button);
state.overrides = [addChild];
state.name = "buttonState";
states.push(state);
}

]]>
</mx:Script>
<mx:VBox id="vbox"/>
<mx:Button click="addTransitions()label="new transition"/>
<mx:Button click="addState()label="new state"/>
<mx:Button click="currentState='buttonState'label="change
state
"/>

</mx:VBox>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 神农架林区| 五华县| 织金县| 陵川县| 资中县| 钦州市| 法库县| 庐江县| 蒲城县| 抚远县| 柳州市| 秦皇岛市| 沈丘县| 白河县| 陵川县| 沁水县| 连云港市| 九江县| 忻城县| 光泽县| 阿拉善右旗| 舟山市| 怀柔区| 商城县| 澄江县| 滦南县| 慈溪市| 新郑市| 广宁县| 晴隆县| 揭西县| 曲麻莱县| 盘锦市| 鱼台县| 盖州市| 德阳市| 昆山市| 益阳市| 朝阳区| 睢宁县| 邹平县|