创建完整声明
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建完成后,您的
acCart
ArrayCollection 已排序;但是,绑定到该 ArrayCollection 的组件应该在将对象添加到 ArrayCollection 时更新。ArrayCollection 是一个非常重的集合,在集合更改时调度事件。
一旦绑定到 DataGrid,对集合的更改将反映在 DataGrid 中。
http://blog.flexdevelopers.com/2009/03/flex-basics -arraycollection.html
创建完成:
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
Creation Complete: