国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

3.23.使用IdeferredInstance 創建模板

2024-04-27 13:51:51
字體:
來源:轉載
供稿:網友
3.23.1 問題
現在你需要創建一個模板組件以處理傳入的多種類型組件,同時也需要延遲實例化組件以提高啟動效率。
3.23.2 解決辦法
使用IdeferredInstance 標記來指定一個數組或者屬性處理所有傳入的組件類型,組件實例化的同時也創建它的子組件。
3.23.3 討論
所有UIComponents 都實現IdeferredInstance 接口并且允許將子組件添加到某個數組中,然后在之后其父組件實例化的時候才實例化這些子組件。所有傳入一個數組的類型為IdeferredInstance 的組件都會保存到它們添加到顯示清單為止,如下所示:
+展開
-XML
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.containers.HBox;
import mx.containers.ViewStack;
import mx.core.UIComponent;
// Define a deferred property for the top component.
public var header:IDeferredInstance;
// Define an Array of deferred properties
// for a row of components.
[ArrayElementType("mx.core.IDeferredInstance")]
public var leftDataRow:Array;
[ArrayElementType("mx.core.IDeferredInstance")]
public var centerDataRow:Array;
[ArrayElementType("mx.core.IDeferredInstance")]
public var rightDataRow:Array;
public var layoutHBox:HBox;
public var layoutWidth:int = 0;
public function createDeferredComponents():void {
addChild(UIComponent(header.getInstance()));
layoutHBox = new HBox();
if(layoutWidth != 0){
layoutHBox.setStyle("horizontalGap", layoutWidth);
}i
if(leftDataRow.length > 0){
var leftVBox:VBox = new VBox();
layoutHBox.addChild(leftVBox);
for (var i:int = 0; i < leftDataRow.length; i++){
leftVBox.addChild(UIComponent(leftDataRow[i].getInstance()));
}
}i
if(centerDataRow.length > 0){
var centerVBox:VBox = new VBox();
layoutHBox.addChild(centerVBox);
for (var i:int = 0; i < centerDataRow.length;
i++)
{c
enterVBox.addChild(UIComponent(centerDataRow[i].
getInstance()));
}
}i
if(rightDataRow.length > 0){
var rightVBox:VBox = new VBox();
layoutHBox.addChild(rightVBox);
for (var i:int = 0; i < rightDataRow.length;
i++)
{
rightVBox.addChild(UIComponent(rightDataRow[i]
.getInstance()));
}
// Add the HBox container to the VBox container.
addChild(layoutHBox);
}

]]>
</mx:Script>
</mx:VBox>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 开封县| 张家港市| 武汉市| 洞头县| 贵港市| 鸡西市| 溧阳市| 鹿邑县| 英吉沙县| 墨脱县| 微山县| 平度市| 祁阳县| 慈利县| 益阳市| 蚌埠市| 滨海县| 八宿县| 黔西县| 农安县| 隆子县| 新余市| 洛川县| 乌鲁木齐市| 罗山县| 博白县| 平顶山市| 商洛市| 修文县| 元氏县| 崇信县| 华安县| 喀喇沁旗| 崇礼县| 宾川县| 平塘县| 崇仁县| 大名县| 洛扎县| 九寨沟县| 彭阳县|