如果您正在寻找动态状态 -这是您的解决方案(前两个状态 -default
和big
- 在编译时添加。第三个状态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
.
如果你想改变子状态,你应该在一个地方有一些已经定义为最小值的实例,然后将它们复制到子组件,但是如果它们都是自定义逻辑有什么意义呢?
所以,让我知道,如果它有帮助。