I'm not exactly sure what you are trying to do but I would create two different events for those functions if events are truly needed. Also, I would recommend extending the Validator class for your spellcheck (I think I've seen a spellcheck class out there somewhere). Depending on what you are trying to do, it may be overkill to use events to process the information. In my code, I write components/classes around a site function or table in a DB. If it's a table in the DB I have a remote object in that class that deals with the different functions like add, modify, and delete. I then assign a button to calling an actionscript function to process the DB call using the remoteobject. The only time I use events is when I need to talk to another class (and it has to be a parent or further up the chain. Event bubbling does not go to parallel classes. eg. <mx:Script> [!Cdata.... private function getData( intUserID: number):void { sameasremotequery( intUSerID ); ... process data } private function saveData( intUserID: number):void { ... call remote object here } </mx:Script> <Remoteobject ,,,> <method id="sameasremotequery" ....> </Remoteobject> <mx:Button id="button" name="getdata" click="getData()"/> There are exceptions to my rule, but for the most part I try to use events where they are needed. Scott
________________________________ From: flexcoders@yahoogroups.com on behalf of secrit.service Sent: Tue 3/24/2009 8:23 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Custom Classes and Custom Events Hi all, The last couple of weeks I wrote my first application in Flex. Today I want to refactor it, meaning : using custom classes and custom events. I have following : I created an application with a couple of buttons and with a custom component (myCustomComp) in it. This custom component is based on a Vbox an contains : - an HBox (mySearchbar) with a textfield and button - a datagrid which contains data from a database - an HBox (myToolbar) with a button and a label The buttons are used for adding, modifying and deleteing records of the database. SO I was thinking of creating a custom event (myCustomEvent). The code I have so far is following : package events { import flash.events.Event; public class myCustomEvent extends Event { public function SpellEvent(type:String) { super(type); } override public function clone():Event{ var evt:myCustomEvent = new myCustomEvent(type); return evt; &nb sp; } } } I was thinking of adding event listners to my buttons. For example my button to add a new record will have a addRecordEventListener. In this listener I create a new instance of myCustEvent and pass my new record as a parameter. The same I will do with my button to delete a record. My question is where and how I should make the difference between the 2 operations. I suppose I have to create a new instance of my event and besides my new record I also need to pass the type of operation : something like new myCustomEvent(newRecord, "addRecord") or new myCustomEvent(newRecord, "deleteRecord"). But in this case, how do I process the different operations? I'm lost and hoping for a clear answer. Thanks -- This message has been scanned for viruses and dangerous content by MailScanner <http://www.mailscanner.info/> , and is believed to be clean.
<<winmail.dat>>