我正在使用带有 Halo 主题的 Flex 4.0,以及我拥有的自定义组件。我想用参数调用组件来隐藏或显示一些项目。该参数是动态的,这意味着它是在加载 mxml 后在方法中设置的。
片段:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
xmlns:ns1="de.aggro.components.*"
width="100%"
height="100%"
initialize="init();"
>
<mx:Script>
<![CDATA[
[Bindable]
public var allowwindowmanipulation:Boolean = true;
internal function init():void {
allowwindowmanipulation = false;
}
]]>
</mx:Script>
<mx:states>
<mx:State name="st">
...
<ns1:CollapsableTitleWindow width="956" height="395" x="294" y="484" id="wnd" title="title" allowClose="{allowwindowmanipulation}">
</mx:State>
</mx:states>
</mx:Application>
CollapsableTitleWindow 代码(片段):
public class CollapsableTitleWindow extends Panel implements ICTWindow {
public var allowClose:Boolean = true;
function CollapsableTitleWindow(){
super();
addEventListener(FlexEvent.CREATION_COMPLETE, initializeHandler);
}
protected override function createChildren():void{
super.createChildren();
//Create the Buttons
closeButton = new Sprite();
if(allowClose==true){
titleBar.addChild(closeButton);
drawCloseButton(true);
}
}
}
现在,当我运行这段代码时,赋予构造函数的值是CollapsableTitleWindow
变量。所以当被调用时,按钮被绘制。true
allowClose
createChildren()
我怎样才能改变行为?如果需要的话,我不介意按钮是否先被绘制,然后再被删除,但我不知道如何进行参数值的这种绑定。
例如,当我将title
属性更改为 时{allowClose}
,会显示布尔值false
,即使true
最初可能传递了 a 。