Thanks Dimitrios.. Question is when the Model.someData changes, will my set dataProvider function be called again ? During my testing it appeared to be called when it was first run, but when the model changed the setProvider function was never called again...
Grant ........................................... > b l u e t u b e i n t e r a c t i v e. .: grant davies .: 404.428.6839 (c) .: 708-983-1577 (F) > [EMAIL PROTECTED] > http://www.bluetube.com/bti -----Original Message----- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dimitrios Gianninas Sent: Sunday, February 18, 2007 11:24 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] observing a model change in cairngorm One way to do it is for the ChartView to manipulate the data as it wishes. So have a setter in the ChartView MXML like so: <bla:ChartView dataProvider="{ModelLocator.someData}"/> And inside the view it looks like so: <mx:Box> <mx:Script> public function set dataProvider( values:XML ):void { ... do stuff here } </mx:Script> ... view stuff here ... </mx:Box> Dimitrios Gianninas Optimal Payments Inc. -----Original Message----- From: flexcoders@yahoogroups.com on behalf of Grant Davies Sent: Sat 2/17/2007 5:57 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] observing a model change in cairngorm gareth, thanks for the response... I think my concern is poluting the model with view specific data... The results of a command is xml and this is set in the model which is an as class (VisitorModel) , the chart bound to the model via its data provider. when the app first starts up, I don't have any xml, a user picks a date range, I hit a web service and get valid xml back, then the chart has to has create a column series based on some labels in the xml, so I need to know when the xml has changed so that the column series can be created and the chart updated. In your example below, does the buildJobsTree just manipulate the data or does it actually do something to the view ? Grant ........................................... > b l u e t u b e i n t e r a c t i v e. .: grant davies .: 404.428.6839 (c) .: 708-983-1577 (F) > [EMAIL PROTECTED] > http://www.bluetube.com/bti <http://www.bluetube.com/bti> A Tribal > Chicken Designs Affiliate <http://www.tribalchicken.com/> ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Gareth Edwards Sent: Saturday, February 17, 2007 5:43 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] observing a model change in cairngorm Why not define an as class for your model (if you aren't already), and define a separate variable that you can populate on the other data being set? The snippet I posted is from something I've done that looks like this.... public function set jobs (data:ArrayCollection <data:ArrayCollection> ) : void { _jobs = data; buildJobsTree(_jobs); } Not sure if its the best option.. but it certainly works for me. Either that, or there are some observer classes from Adobe Consulting that allow you to watch changes to your model from the UI. Cheers Gareth. Grant Davies wrote: Thanks gareth.. the model is used by multiple views, a grid and a chart, the chart needs the xml from the model manipulated a little differently than the grid does... grant ........................................... > b l u e t u b e i n t e r a c t i v e. .: grant davies .: 404.428.6839 (c) .: 708-983-1577 (F) > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > http://www.bluetube.com/bti <http://www.bluetube.com/bti> > A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/> ________________________________ From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Gareth Edwards Sent: Saturday, February 17, 2007 4:32 PM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: Re: [flexcoders] observing a model change in cairngorm Why not use a setter in your model and do the work there? public function set jobs (data:ArrayCollection <data:ArrayCollection> ) : void { // Custom logic here? _jobs = data; } Cheers Gareth. Grant Davies wrote: Hi guys, I've got my view, model, commands and delegate all running and my view contains a chart. When the model changes for my chart data I need to work the data a little and can't just directly use the binding. do I 1) change my command to fire an event when the model has been updated 2) Is there some way I can observe a model change and then kick of my "data work" a little and not directly bind the chart to the model ? Grant ........................................... > b l u e t u b e i n t e r a c t i v e. .: grant davies .: 404.428.6839 (c) .: 708-983-1577 (F) > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > http://www.bluetube.com/bti <http://www.bluetube.com/bti> > A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/>