带有中继器的 Flex ViewStack - 中继器放置在底部

发布于 2024-09-18 05:19:34 字数 979 浏览 10 评论 0原文

我在创建 ViewStack 时遇到问题,其中包含一个转发器以及 ViewStack 内的其他组件(即 vBox)。中继器放置在视图的底部。尽管中继器列在其他组件之前,但它被放置在底部。

有没有一种解决方法可以让我在其他组件之前绘制中继器?

我用谷歌搜索了这个问题,其他人在另一个网站上问了同样的问题,但没有人回答。我正在粘贴他们帖子中的示例代码。中继器最后绘制。

谢谢

这是一个例子:

<mx:ViewStack id="viewStack" width="100%" height="100%" backgroundColor="#FFFFFF" 
         backgroundAlpha="1" paddingLeft="5" paddingRight="5" paddingBottom="5">

    <mx:Repeater id="editorsRP" dataProvider="{dynamicFields}" 
          repeatEnd="organizeViewStack();" width="100%" height="100%">

        <editor:DynamicFieldEditor label="{FieldGroup(editorsRP.currentItem).name}" 
              width="100%" height="100%" fields="{FieldGroup(editorsRP.currentItem).fields}" dataProvider="{details}" />

    </mx:Repeater>

    <editor:NotesEditor id="notesEditor" width="100%" height="100%" label="Notes" 
         enabled="false" notesProvider="{attachment}" />

</mx:ViewStack>

I have a problem when creating a ViewStack, with a repeater along with other components (i.e. vBox) inside the ViewStack. The repeaters get placed at the bottom of the view. Despite the repeater is listed before other components, it is placed at the bottom.

Is there a workaround where I can get the repeater drawn before the other components?

I googled this and someone else asked the same question on another site, but no one answered. I am pasting sample code from their post. The repeater is drawn last.

Thanks

Here is an example:

<mx:ViewStack id="viewStack" width="100%" height="100%" backgroundColor="#FFFFFF" 
         backgroundAlpha="1" paddingLeft="5" paddingRight="5" paddingBottom="5">

    <mx:Repeater id="editorsRP" dataProvider="{dynamicFields}" 
          repeatEnd="organizeViewStack();" width="100%" height="100%">

        <editor:DynamicFieldEditor label="{FieldGroup(editorsRP.currentItem).name}" 
              width="100%" height="100%" fields="{FieldGroup(editorsRP.currentItem).fields}" dataProvider="{details}" />

    </mx:Repeater>

    <editor:NotesEditor id="notesEditor" width="100%" height="100%" label="Notes" 
         enabled="false" notesProvider="{attachment}" />

</mx:ViewStack>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

节枝 2024-09-25 05:19:34

我相信问题出在 dataProvider 设置/更改其值时。

上面的代码中没有显示这一点,因此很难知道。但是,每当此值发生更改时,转发器创建的现有子级将从父级中删除,并添加新的。

如果 ViewStack 的子级已经创建,则转发器中的子级将放置在现有子级之后。

例如:

 <mx:TabNavigator width="500">
      <mx:VBox label="Static 1" />
      <mx:Repeater dataProvider="{['a','b','c']}">
          <mx:VBox label="From repeater" />
      </mx:Repeater>
      <mx:VBox label="Static 2" />
  </mx:TabNavigator>

在此实例中,dataProvider 在转发器初始化期间设置,因此选项卡按顺序显示:

¦ Static 1 ¦ From Repeater ¦ From Repeater ¦ From Repeater ¦ Static 2 ¦

但是,如果 dataProvider 的值更改(或 dataProvider 调度 CollectionChangeEvent),则 3 个转发器子级将是删除,并添加新的子项。这将保留 Tab 键顺序:

¦ Static 1 ¦ Static 2 | From Repeater ¦ From Repeater ¦ From Repeater ¦

我注意到您已将 organizeViewStack 方法连接到 repeatEnd 事件处理程序 - 尽管未显示该方法的代码。

这看起来是管理这个问题的最佳方法——一旦孩子们的顺序被设定,就重新调整他们的顺序。

I believe the problem is when the dataProvider is having it value set / changed.

This isn't shown in the code above, so it's hard to know. However, whenever the value of this is changed, the existing children created by the repeater will be removed from the parent, and new ones will be added.

If the ViewStack's children have already been created, then the children from the repeater will be placed after the existing children.

For example:

 <mx:TabNavigator width="500">
      <mx:VBox label="Static 1" />
      <mx:Repeater dataProvider="{['a','b','c']}">
          <mx:VBox label="From repeater" />
      </mx:Repeater>
      <mx:VBox label="Static 2" />
  </mx:TabNavigator>

In this instance, the dataProvider is set during the initialization of the repeater, so the tabs appear in order:

¦ Static 1 ¦ From Repeater ¦ From Repeater ¦ From Repeater ¦ Static 2 ¦

However, if the value of the dataProvider changes (or the dataProvider dispatches a CollectionChangeEvent), then the 3 repeater children would be removed, and new children added. This would leave the tab order:

¦ Static 1 ¦ Static 2 | From Repeater ¦ From Repeater ¦ From Repeater ¦

I notice you've wired an organizeViewStack method to the repeatEnd event handler - although the code for the method isn't shown.

This looks like the best way of managing this - reshuffling the order of the children once they've been set.

偷得浮生 2024-09-25 05:19:34

我猜测了一下,但是

ViewStack 的所有子级都必须是容器。 Repeater 不是一个容器。因此,它作为 ViewStack 子级的放置是无关紧要的,因为出于所有意图和目的,它都会被忽略。

然而,当转发器执行时,它会创建一堆容器并将它们添加到父容器(又名 ViewStack)中;从而为它们提供与您从代码中期望的不同的 Z 顺序。

您是否正在尝试创建 ViewStack 的许多不同子级?或者您是否期望“DynamicFieldEditors”以某种方式堆叠?

I'm guessing a bit, but

All of a ViewStack's children must be a container. The Repeater is not a container. So, it's placement as a ViewStack children is irrelevant, because for all intents and purposes it is ignored.

However, when the repeater executes it creates a bunch of containers and adds them to the parent (AKA ViewStack); thus giving them a different Z-order than what you might expect from the code.

Are you trying to create many different children of the ViewStack? Or are you expecting the "DynamicFieldEditors" to be stacked somehow?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文