2 Replies Latest reply on Dec 31, 2008 7:41 AM by Newsgroup_User

    differentiating between button actions

    kilyas2007 Level 1
      I have three buttons in my application. Each one of them calls the same method on click:-

      <mx:Button id="addReport" label="Add" styleName="buttonSkin" width="25%" click="submitUpdate(event);"/>
      <mx:Button id="updateReport" label="Update" styleName="buttonSkin" width="25%" click="submitUpdate(event);"/>
      <mx:Button id="removeReport" label="Remove" styleName="buttonSkin" width="25%" click="submitUpdate(event);"/>

      Is there a way that in the submitUpdate, I can differentiate between the calls based on which one these buttons were clicked? Or wording it differently can I find out which button was clicked for issuing this command?
        • 1. Re: differentiating between button actions
          Level 7

          "kilyas2007" <webforumsuser@macromedia.com> wrote in message
          news:gjg3gl$r8v$1@forums.macromedia.com...
          >I have three buttons in my application. Each one of them calls the same
          >method
          > on click:-
          >
          > <mx:Button id="addReport" label="Add" styleName="buttonSkin" width="25%"
          > click="submitUpdate(event);"/>
          > <mx:Button id="updateReport" label="Update" styleName="buttonSkin"
          > width="25%" click="submitUpdate(event);"/>
          > <mx:Button id="removeReport" label="Remove" styleName="buttonSkin"
          > width="25%" click="submitUpdate(event);"/>
          >
          > Is there a way that in the submitUpdate, I can differentiate between the
          > calls
          > based on which one these buttons were clicked? Or wording it differently
          > can I
          > find out which button was clicked for issuing this command?

          event.target

          HTH;

          Amy


          • 2. Re: differentiating between button actions
            buabco Level 1
            use event.target

            like this:
            if (event.target == addReport) {
            } else if (event.target == updateReport) {
            } else {}