Tom, I have a similar problem with a class that inherits from DataProvider.
As a side note, conceptually related to what you were doing. I have built a dataprovider filter framework that can connect different dataproviders through filters and creates what I call dataprovider views ( as in table->view ). It propragates events so a change in a view field will eventually make all binded components (even those binded to another view of the same data) to refresh themselves accordingly. Just think about the table -> view relation and how powerful it can become if the conditions (filters) are dynamic and binded to controls. A shopping cart dataprovider can be created as a dataprovider view that filters on a selectedFlag boolean property, over the complete items dataprovider, for example. You can then bind the shopping cart dataprovider to any component for display, and you can rely on the framework to update the data as the user selects more items. It is quite simple to develop really, but very powerful. I believe you could create something along that lines for what you are doing. Take a look at Manish Jethani's filtereddataprovider for a starting point on the filters structure. Ah, beware the getItemID method implementation ( or lack thereof ). Best, Aldo On 7/25/05, Matt Chotin <[EMAIL PROTECTED]> wrote: > > > > That is odd. I found that when I changed the type of globalModel from > DataProvider to Array the length returned correctly. Must be some weird > casting going on in the VM that's screwing things up. > > > > Matt > > > > ________________________________ > > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Tom Jeffery > Sent: Friday, July 22, 2005 10:43 AM > To: [email protected] > Subject: [flexcoders] DataProvider API doing strange things... very > confused! > > > > I wrote some sample code to try to help me figure out how to properly > create and use a global instance of data throughout my Flex > application. The idea was to create an actionscript class that > contains a static instance of an Array / DataProvider, initialize it > on creation of the application, and then bind multiple components to > it, so they would all update when a modelChanged event was broadcast. > > With debug printouts or using an object inspector, I'm seeing some > really strange behavior with this sample application. If I add an > item to the global array, it shows up on the two lists, but doesn't > actually appear in the array, and the array size doesn't get any > bigger. If I delete an item, the item gets deleted from both lists > and the array, but again, the array.length property remains unchanged. > > Am I just missing something simple here about how to do this? My two > source files and xml data are pasted here if you'd like to try them > out and see if you can spot what it is that I'm doing wrong. > > Thanks for any assistance! > -Tom Jeffery > > --- GlobalModel.as --- > import mx.controls.listclasses.DataProvider; > > class GlobalModel { > static var globalModel:DataProvider; > } > > > --- data.xml --- > <data> > <item> > <label>Test Item 1</label> > </item> > > <item> > <label>Test Item 2</label> > </item> > > <item> > <label>Test Item 3</label> > </item> > > <item> > <label>Test Item 4</label> > </item> > </data> > > > --- DataTest.mxml --- > <?xml version="1.0" ?> > <mx:Application xmlns="*" > xmlns:mx="http://www.macromedia.com/2003/mxml" > width="100%" > height="100%" > xmlns:local="*" creationComplete="doInit();" > > > <!-- <local:Inspect/>--> > > <mx:Script> > <![CDATA[ > import GlobalModel; > import mx.controls.listclasses.DataProvider; > > function addText():Void { > //testModel.item.addItem(testInput.text); > GlobalModel.globalModel.addItem(testInput.text); > //testList1.addItem(testInput.text); > } > > function deleteItem():Void { > if (testList1.selectedIndex == undefined) > return; > GlobalModel.globalModel.removeItemAt(t > estList1.selectedIndex); > } > > function doInit():Void { > GlobalModel.globalModel = testModel.item; > } > ]]> > </mx:Script> > > <mx:Model id="testModel" source="./data.xml"/> > > <mx:VBox> > <mx:HBox> > <mx:List id="testList1" dataProvider="{testModel.item}" > multipleSelection="false" /> > <mx:List id="testList2" > dataProvider="{GlobalModel.globalModel}" > selectable="false" /> > </mx:HBox> > <mx:HBox> > <mx:TextInput id="testInput" /> > <mx:Button id="testButton" click="addText();" > label="Add To Model > {GlobalModel.globalModel.length}" /> > <mx:Button click="deleteItem()" label="Delete Selected"/> > </mx:HBox> > </mx:VBox> > > </mx:Application> > > > > > > > > -- > Flexcoders Mailing List > FAQ: > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > > > > > SPONSORED LINKS > Computer software testing Macromedia flex Development > Software developer > > ________________________________ > YAHOO! GROUPS LINKS > > > Visit your group "flexcoders" on the web. > > To unsubscribe from this group, send an email to: > [EMAIL PROTECTED] > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. > > ________________________________ > > > -- ::::: Aldo Bucchi ::::: mobile (56) 8 429 8300 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

