Hi All,
I have a problem with data binding on my custom component.
If my myModel.tokens (arraycollection) was modified somewhere else (i.e. in
front controller)
the "set dataProvider" function never gets called. The doThisFunction() only
gets called
once, during the ui component instantiation I would guess.
I'm changing the contents of myModel.tokens using only:
myModel.tokens.removeAll();
myModel.tokens.addItem(obj);
Parent Component:
[Bindable]
public var myModel:MyModel; // myModel.tokens is an
arraycollection. MyModel class is marked as Bindable
...
<mycomp:CustomLabel id="keywordList" dataProvider="{myModel.tokens}" />
CustomLabel.mxml:
private var _dataProvider:ArrayCollection;
private var dataProviderChanged:Boolean = false;
...
override protected function commitProperties():void {
super.commitProperties();
if (dataProviderChanged) {
doThisFunction();
dataProviderChanged = false;
}
}
...
public function set dataProvider(tokens:ArrayCollection):void {
_dataProvider = tokens;
dataProviderChanged = true;
invalidateProperties();
}
...
private function doThisFunction():void {
//....iterate over array and display on screen...
}
How do I make sure the set dataprovider function gets triggered when the
contents of tokens changes? Whats wrong with my code?
-Stephen