创建完整声明

发布于 2024-12-11 22:58:31 字数 769 浏览 0 评论 0原文

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
           creationComplete="init()">

这是我的标头,这是由creationComplete 调用的函数:

protected function init():void
        {
            var mySort:Sort = new Sort();
            mySort.fields = [new SortField('title')];
            acCart.sort = mySort;
            acCart.refresh();
        }

现在,我基本上将一些对象从一个数组集合(商店)添加到另一个数组集合(购物车)(在数据网格中显示)。每次我按下“添加到购物车”按钮时,购物车数据网格都会被修改。

我以为creationcomplete语句只执行一次,但现在我有疑问,因为它是唯一包含refresh()的函数,如果我删除它,我的购物车就不再更新了。有人可以向我提供有关创建完整声明的更多信息吗?在互联网和教科书中进行的搜索并没有让我了解它到底是做什么的。

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
           creationComplete="init()">

This is my header, and this is the function that is being called by creationComplete:

protected function init():void
        {
            var mySort:Sort = new Sort();
            mySort.fields = [new SortField('title')];
            acCart.sort = mySort;
            acCart.refresh();
        }

Now, I'm adding some objects from one arraycollection (shop) to another (cart) basically (shown in a datagrid). The cart-datagrid is being modified everytime I press the button "add to cart".

I thought that the creationcomplete-statement was only executed once, but now I'm in doubt, because it's the only function that contains the refresh() and if I delete it, my cart isn't updatet anymore. Can somebody provide me with some more information about the creationcomplete statement? A search on the internet and in my textbook hasn't learned me what it exactly does.

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

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

发布评论

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

评论(1

洛阳烟雨空心柳 2024-12-18 22:58:31

创建完成后,您的 acCart ArrayCollection 已排序;但是,绑定到该 ArrayCollection 的组件应该在将对象添加到 ArrayCollection 时更新。

ArrayCollection 是一个非常重的集合,在集合更改时调度事件。

一旦绑定到 DataGrid,对集合的更改将反映在 DataGrid 中。

http://blog.flexdevelopers.com/2009/03/flex-basics -arraycollection.html

...ArrayCollection 是一个“将 Array 公开为
可以使用方法和操作来访问和操作的集合
ICollectionView 或 IList 接口的属性”。
ArrayCollection 类的两个成员对于 ArrayCollection 支持数据绑定的能力至关重要 -
collectionChange 事件和 addEventListener 方法。参加
数据绑定,对象必须能够:

  1. 当事情发生变化时调度事件
  2. 允许其他对象监听并响应事件

创建完成:

当组件及其所有子组件以及所有
他们的孩子等等,已经被创建、布置并被
可见。

当这些情况发生时,Flex 会为容器调度creationComplete 事件
最初需要的子项已得到充分处理和利用
屏幕,包括所有需要的孩子的孩子,等等
在。为creationComplete事件创建一个监听器,例如,如果
您必须了解活动中儿童的尺寸和位置
处理程序。不要将creationComplete事件用于设置的操作
布局属性,因为这样做会导致过多的处理时间。

Upon creation complete, your acCart ArrayCollection is sorted; however, components bound to that ArrayCollection should update upon adding objects to an ArrayCollection.

ArrayCollection is a very heavy collection, dispatching events upon collection change.

Once bound to a DataGrid, alterations to the collection will be reflected within the DataGrid.

http://blog.flexdevelopers.com/2009/03/flex-basics-arraycollection.html

...an ArrayCollection is a "wrapper class that exposes an Array as a
collection that can be accessed and manipulated using the methods and
properties of the ICollectionView or IList interfaces".
Two members of the ArrayCollection class are integral to the ArrayCollection's ability to support data binding - The
collectionChange event and addEventListener method. To participate in
data binding, an object must be able to:

  1. dispatch an event when something changes
  2. allow other objects to listen and respond to event

Creation Complete:

Dispatched when the component, and all its child components, and all
their children, and so on, have been created, laid out, and are
visible.

Flex dispatches the creationComplete event for a container when those
children that are initially required are fully processed and drawn on
the screen, including all required children of the children, and so
on. Create a listener for the creationComplete event, for example, if
you must have the children’s dimensions and positions in your event
handler. Do not use the creationComplete event for actions that set
layout properties, as doing so results in excess processing time.

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