Sorry G, missed your 2nd question. Unfortunately, an Array is the ONLY thing you can bind to using a ModelLcoator approach (al la Cairngorm/ARP). So, this is technically the de-facto way to do binding in Flash.
----- Original Message ----- From: "JesterXL" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <[email protected]> Sent: Monday, January 02, 2006 5:08 PM Subject: Re: [Flashcoders] dataProvider questions A dataProvider is a getter/setter property. It is typically an Array, but can be an Object. Array's have their prototype changed when you use the v2 component framework. They have methods added to them, and these methods make up the DataProvider API. This API is used to add data to the array, and broadcast changes so components who use the dataProvider know what to do when changes occur. DataProviders are created to allow many different Views to show and operate on data in the dataProvider. Example: a = ["one", "two", "three"]; my_list.dataProvider = a; Your List on the stage called "my_list" will now show the 3 items in the list. If you threw that at a DataGrid, and the DataGrid was editable, you could actually edit the items in the array. Additionally, those changes would be broadcast to any other View that used a as the dataProvider. You cannot do this with normal arrays, since doing this: a.push("four"); Does nothing other than add data. This, however: a.addItem("four"); Broacasts an event using EventDispatcher so all UIComponents who implement the DataProvider API know what to do. If you want to create compoenents that utilize the DataProvider, you have 2 chocies: - implement a getter/setter property of dataProvider, and register for a modelChanged event. When that occurs, redraw your component. Optionally, you can support DataProvider API methods via proxy. Example: public function addItemAt(index:Number, o:Object):Void { dataProvider.addItemAt(index, o); } The API is discussed heavily in the updated MX 2004 (7.2) documentation. - The 2nd, and best way, is to utilize DataSelector. DataSelector is a mixin, but I highly suggest you instead create an abstract base class (meaning only created for the sake of extending it), use the DataSelector mixin on the base class, and then extend the base class. The reason for this is 2 fold: first, you have a LOT less code in your extended class since the DataSelector mixin adds A LOT; second, you can listen for modelChanged without using hacks. DataSelector will do a bunch of things. Mainly: - give your component dataProvider powers - your component automatically implements the DataProvider API - you get properties like selectedItem, selectedIndex, etc. For more info, check out: http://www.jessewarden.com/archives/2005/06/dataselector_da.html http://www.jessewarden.com/archives/2005/10/using_dataselec.html http://www.jessewarden.com/archives/2004/07/how_to_get_data.html ----- Original Message ----- From: "Rich Rodecker" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <[email protected]> Sent: Monday, January 02, 2006 4:55 PM Subject: [Flashcoders] dataProvider questions I'm having a little trouble with dataProviders. I'm trying to search around for info but I'm getting a little confused. I'm going to try and ask some q's... if anyone can help me out, that would be great. I used to work with it back in flash mx, but it looks like its changed a lot. First, does anyone know of anyplace I can get some good solid info on DataProvider? the documentation in mx04 doesnt really do it for me. I am creating a custom component, and would like it to be data-aware. Looks like I need to create a dataProvider property in my components class, right? Now, how do I go about binding the dataProvider property to a separate Model class (I want to bind it to a property of ModelLocator in ARP, if anyone is familiar) -- am I actaully talking about two different things here?. I would also like to be able to set the dataProvider from an xml object too (in other instances of the component). _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

