Friday, July 27, 2007

Conditional visualization in Cairngorm 2.x using the ChangeWatcher class

http://blog.comtaste.com/2007/07/conditional_visualization_in_c_1.html

package ...
{
...

public class MyViewHelper extends ViewHelper
{
private var myChangeWatcher:ChangeWatcher;

public function MyViewHelper() {

myChangeWatcher = ChangeWatcher.watch(MyModelLocator.getInstance(), “myDataSource”, prepareDataProvider);
}


private function prepareDataProvider(event:Event) {

var myAC:ArrayCollection = new ArrayCollection();
for each(var item:Object in MyModelLocator.getInstance().myDataSource) {
//if item satisfies certain conditions
myAC.addItem(item);
}
view.myDataProvider = myAC;
}

}
}

No comments: