Flex 4 自定义组件,其子组件直接插入视图堆栈
我放弃。希望我只是错过了一些简单的事情,但我觉得我正在努力让它发挥作用。我想要的只是一个自定义的“向导”组件,其子组件放置在 ViewStack 中,并且在 ViewStack 下方有一个“下一步”和“后退”按钮。以下是一些代码摘录,用于说明我的方法:
WizardGroup.as:WizardGroupSkin.mxml
[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();
:
<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 的子级。因此视图堆栈始终只有一个子级:contentGroup。
我还尝试了将视图堆栈的内容绑定到 contentGroup 的子级的方法,但是使用 Spark 容器,无法访问子级数组或元素数组(即,没有 contentGroup.getChildren() 或contentGroup.getElements())
有什么想法吗?谢谢大家。
I give up. Hopefully I am just missing something easy, but I feel like I am pulling teeth trying to get this to work. All I want is a custom 'wizard' component whose children are placed within a ViewStack and beneath the ViewStack there is a next and back button. Here are some code excerpts to illustrate my approach:
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>
While this comes very close to working, the major problem is that the children of the WizardGroup component are not added as children of the viewstack. Instead, they are added as children of the contentGroup. So the viewstack will always only have one child: contentGroup.
I also tried the approach of binding the contents of the view stack to the children of contentGroup, but with Spark containers, there is no way to access an array of children or array of elements (ie, there is no contentGroup.getChildren() or contentGroup.getElements())
Any ideas? Thanks everyone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于想通了。诀窍是将 WizardGroup 的默认属性设置为我称之为“content”的公共成员数组,
然后在皮肤中,将视图堆栈的内容绑定到 hostComponent 的内容数组:
I finally figured it out. The trick is to set the default property of the WizardGroup to a public member array I am calling "content"
And then within the skin, bind the content of the viewstack to the hostComponent's content array: