4 Replies Latest reply on Aug 11, 2010 1:48 AM by LemanRus

    Event Class

    LemanRus

      Pardon my newbie ness

       

      I'm trying to understand what the relevance of "onSubmit" has in the declaration

       

      public static const USER_FORM_SUBMIT:String = "onSubmit";

       

      Many Thanks

       

      LeMan

        • 1. Re: Event Class
          BhaskerChari Level 4

          Hi LeMan,

           

          Your question is not fully clear...can you please elaborate..??

           

           

          Thanks,

          Bhasker

          • 2. Re: Event Class
            Bogdan Manate

            Hello LeMan

             

            You can in that declaration any string you want, but you must be sure that

            your class doesn't dispatch an event with the same type. Here is an exemple.

             

            If you have a class extened from event and you have many declarations like

            these:

             

            public static const FORM_RESET:String = "form"; // wrong

            public static const FORM_SUBMIT:String = "form"; // wrong the if you

            dispatch an event of type FORM_SUBMIT the event listeners added to

            FORM_RESET will also catch the event.

            public static const FORM_VALIDATE:String = "formValidate";

             

            I hope I was very clear, if not you can post a new question.

            • 3. Re: Event Class
              BhaskerChari Level 4

              I dont think this is the real significane of decalring the static constants in the Event class...

               

              There is no question of decalring the same srting value with two different constants...

               

              The main and real purpose of declaring the static constants in Event class to avoid typos when you dispatch the events...

               

              If you do not specify the static constant in the Event class then you need to manually type the string for event type and dispatch the event...However

               

              if you specify the static constant you can directly use the static constant by referencing the Event class name there by avoiding the typos and dispatching the

              correct event to be handled..

               

              If you make typos in dispatching your event then there is no question of handling the event correctly..


              dispatchEvent(new EventClass(EventClass.USER_FORM_SUBMIT));// correct and good approach

               

              dispatchEvent(new EventClass("onSubmit"));// correct but not a good approach

               


              Thanks,

              Bhasker Chari

              • 4. Re: Event Class
                LemanRus Level 1

                Thank you

                Bogdan Manate and

                BhaskerChari. After writing the request it kind of dawned on me but you guys have nailed it down.

                Cheers!