[英]Is Flex 4 Panel's controlBarContent dynamic?
我有一個擴展 spark.componenets.TitleWindow 的自定義 TitleWindow 組件(用 ActionScript 編寫)
我想在控制欄中定義一些控件,但在創建階段我沒有所有控件。 此外,此自定義組件是其他需要控制欄中其他控件的組件的基礎。
有沒有辦法在運行時向 ActionScript 中的 controlBarContent 添加控件?
也許像下面這樣? (這顯然不起作用)
controlBarContent = [];
.
.
.
controlBarContent.push(new Button());
一般來說,要注意
addElement()
或者
addChild()
方法。
addElement() 將其他 UI 組件添加為其他組件的子元素。
這可能很有趣。 最后,Adobe 在這里提供了很好的幫助: “使用組件” 。
更新-1
對不起,我的錯。 這對我有用:
<s:Panel creationComplete="init();" id='p' controlBarVisible="true" >
<s:controlBarContent>
<!-- will show controls -->
<s:Button label="dd">
</s:Button>
</s:controlBarContent>
<fx:Script>
<![CDATA[
import mx.controls.Button;
import spark.components.Button;
private function init(): void {
var s:spark.components.Label = new spark.components.Label();
s.text = 'My Label';
s.width = 200;
var a:Array = new Array();
a.push( s );
p.controlBarVisible = false;
p.controlBarContent = a;
p.controlBarVisible = true;
p.invalidateDisplayList();
}
]]>
</fx:Script>
</s:Panel>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.