如果您正在尋找動態 - here是您的解決方案(前兩種狀態 - default
和big
- 都是adde d在編譯時。第三狀態Bang-a-Gong
在運行時添加的):
private function init():void {
// Create a new state and give it a name.
var stateBang:State = new State();
stateBang.name = 'Bang-a-Gong';
// Set the overrides with an array of AddChild, AddItems,
// RemoveChild, SetEventHandler, SetProperty, and SetStyle
stateBang.overrides =
[ new SetProperty(btn, "label", "Bang-a-Gong"),
new SetProperty(btn, "height", "150"),
new SetProperty(btn, "width", "300"),
new SetStyle(btn, "fontSize", "22"),
new SetStyle(btn, "fontWeight", "bold"),
new SetStyle(btn, "color", "#FF0000") ];
// Add our new state to the available states of this component.
this.states.push(stateBang);
// Just for kicks lets add a transition for this state.
var transition:Transition = new Transition();
transition.toState = 'Bang-a-Gong';
// Create a new transition effect.
var resize:Resize = new Resize(btn);
// Create an composite effect, either: Sequence or Parallel.
var sequence:Sequence = new Sequence();
// Add our resize effect.
sequence.addChild(resize);
// now add our composition effect to the transition we created.
transition.effect = sequence;
// Push our new transition into the transitions array for this component.
this.transitions.push(transition);
}
在另一種情況下,如果我在正確的方式理解,你應該在主要應用程序中創建一些對象,並通過FlexGlobals.topLevelApplication
從所有子組件訪問它。
如果您想更改子狀態,您應該將已定義狀態的實例作爲最小值在一個位置,然後將它們複製到子組件,但是如果它們都是自定義邏輯又有什麼意義?
所以,讓我知道,如果它有幫助。
FlexGlobals.topLevelApplication.yourObject.isSuperuser == true – Eugene 2010-09-19 17:24:12