我放棄了。希望我只是想念一些簡單的事情,但我覺得我正在試圖讓這個工作。我想要的只是一個自定義的「嚮導」組件,其子組件位於ViewStack中,在ViewStack下方有一個下一個和後退按鈕。下面是一些代碼摘錄來說明我的方法:Flex 4自定義組件,兒童直接插入視圖堆棧
WizardGroup.as:
[SkinPart(required="true")]
public var nextBt:Button = new Button();
[SkinPart(required="true")]
public var backBt:Button = new Button();
[SkinPart(required="true")]
public var stack:ViewStackSpark = new ViewStackSpark();
WizardGroupSkin.mxml:
<s:VGroup width="100%" height="100%"
paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10">
<container:ViewStackSpark id="stack" width="100%" height="100%">
<s:Group id="contentGroup" width="100%" height="100%" minWidth="0" minHeight="0"/>
</container:ViewStackSpark>
<s:HGroup horizontalAlign="right" width="100%">
<s:Button id="nextBt" label="Next" enabled="{hostComponent.permitNext}" enabled.last="false"/>
<s:Button id="backBt" label="Back" enabled="{hostComponent.permitBack}" enabled.first="false"/>
</s:HGroup>
</s:VGroup>
儘管這非常接近的工作,主要的問題是, WizardGroup組件的子項不會添加爲視圖堆棧的子項。相反,它們將作爲contentGroup的子項添加。所以viewstack總是隻有一個孩子:contentGroup。
我也嘗試了將視圖堆棧的內容綁定到contentGroup的子項的方法,但是對於Spark容器,無法訪問子元素或元素數組(即沒有contentGroup。 getChildren()或contentGroup.getElements())
任何想法?感謝大家。