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;
             }

  }

}

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

Reply via email to