我正在嘗試實現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