国产探花免费观看_亚洲丰满少妇自慰呻吟_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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桂东县| 上饶市| 久治县| 象山县| 凯里市| 汨罗市| 西华县| 江华| 九龙城区| 五华县| 天全县| 巍山| 卢龙县| 桦南县| 都昌县| 肃北| 神木县| 双峰县| 嘉定区| 临夏县| 西林县| 资讯 | 敖汉旗| 平远县| 庄浪县| 廊坊市| 长顺县| 左云县| 武川县| 江津市| 临夏县| 新津县| 荆门市| 道孚县| 四川省| 都兰县| 黄浦区| 靖西县| 兴文县| 华池县| 西安市|