mark goldin escreveu: > Yes, I can create a generic method for my Grid: > public function doSomethingAfterRowIsAdded():void > { > } > But I can't have any code there because it is specific to an object > instatiation. > > > */Frederico Garcia <[EMAIL PROTECTED]>/* wrote: > > markgoldin_2000 escreveu: > > I am designing a custom ListGrid. Most of functionality will be > in the > > base class. But some will deppend on a specific instatiation. For > > example, when new row is added to the ListGrid I need to run > additional > > code for each object being instatiated from the base class. And > that > > code is unique for each object. Any idea how set this up properly > > meaning keeping everything as generic as possible. > > > > Thanks > > > > > > > > -- > > Flexcoders Mailing List > > FAQ: > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> > > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > <http://www.mail-archive.com/flexcoders%40yahoogroups.com> > > Yahoo! Groups Links > > > > > > > > > > __________ NOD32 2747 (20071225) Information __________ > > > > This message was checked by NOD32 antivirus system. > > http://www.eset.com <http://www.eset.com/> > > > > > > > > > Maybe you could create a function on every object always with the > same > name, and when you had a object to the list you check if th function > exists. If it does you execute it, else you do nothing. You can > see the > same principle in clonable objects (having a function called > /clone()/) > > Regards, > > Frederico Garcia > > > > > __________ NOD32 2747 (20071225) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com What I meant was having a function on the Object added to the grid, not on the grid itself. Something like this:
public class CustomGrid extends DataGrid { (...) override public function addElement(value:Object):void { super.addElement(value); executeCustomCode(value); } public function executeCustomCode(value:Object):void { try { value.customFunction(); } catch(error:TypeError) { // ADD YOUR DEFAULT CODE HERE } } } The syntax is not correct but it gives you the big picture. To improve this you could had a listener on /added/ to the dataProvider that triggered the executeCustomCode function. Hope this helps, Frederico Garcia