Flex 4 自定义组件,其子组件直接插入视图堆栈

发布于 2024-09-06 23:34:08 字数 1487 浏览 10 评论 0原文

我放弃。希望我只是错过了一些简单的事情,但我觉得我正在努力让它发挥作用。我想要的只是一个自定义的“向导”组件,其子组件放置在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清晰传感 2024-09-13 23:34:08

我终于想通了。诀窍是将 WizardGroup 的默认属性设置为我称之为“content”的公共成员数组,

[DefaultProperty("content")]
public class WizardGroup extends TitleWindow
{
    [SkinPart(required="true")]
    public var nextBt:Button = new Button();

    [SkinPart(required="true")]
    public var backBt:Button = new Button();

    [Bindable]
    public var content:Array;

然后在皮肤中,将视图堆栈的内容绑定到 hostComponent 的内容数组:

        <s:VGroup width="100%" height="100%"
                  paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10">
            <container:ViewStackSpark id="stack" width="100%" height="100%" content="{hostComponent.content}"/>
            <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>

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"

[DefaultProperty("content")]
public class WizardGroup extends TitleWindow
{
    [SkinPart(required="true")]
    public var nextBt:Button = new Button();

    [SkinPart(required="true")]
    public var backBt:Button = new Button();

    [Bindable]
    public var content:Array;

And then within the skin, bind the content of the viewstack to the hostComponent's content array:

        <s:VGroup width="100%" height="100%"
                  paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10">
            <container:ViewStackSpark id="stack" width="100%" height="100%" content="{hostComponent.content}"/>
            <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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文