我正在尝试实现ArrayCollection对象的2路绑定。但是,COLLECTION_CHANGE事件不会触发。Flex 4 COLLECTION_CHANGE事件没有触发
App.mxml
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:components="components.*"
creationComplete="handleCreationComplete(event)">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var booths:ArrayCollection;
public function handleCreationComplete(event:Event):void
{
// ADD SOME BOOTHS
booths = new ArrayCollection();
booths.addItem("item1");
booths.addItem("item2");
}
]]>
</fx:Script>
<components:FloorplanGrid id="grid" width="400" height="300" booths="{booths}" />
</s:Application>
FloorplanGrid.as
package components
{
import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;
import spark.components.Group;
[Event(name="collectionChanged", type="events.CollectionEvent")]
public class FloorplanGrid extends Group
{
[Bindable]
public var booths:ArrayCollection = new ArrayCollection();
public function FloorplanGrid()
{
booths.addEventListener(CollectionEvent.COLLECTION_CHANGE, handleBoothsChange);
super();
}
private function handleBoothsChange(event:CollectionEvent):void
{
trace("HANDLE BOOTHS CHANGE");
/* draw booths */
}
}
}
我试图实现2路与摊位变量绑定。
public var booths:ArrayCollection = new ArrayCollection();
但后来:然而,当我加在App.mxml