2 Replies Latest reply on Apr 30, 2006 8:10 AM by Newsgroup_User

    Adding a listener to ALL buttons

    matecito
      I have about 70 buttons on a page - and I want all of them to get the same eventlistener... can I add it to all of them with one fell swoop?
        • 1. Re: Adding a listener to ALL buttons
          kglad Adobe Community Professional & MVP
          what are you trying to do?
          • 2. Re: Adding a listener to ALL buttons
            Level 7
            Are these Flash Component UI buttons or your own custom buttons?

            With Flash Component UI buttons, this is not a problem. Ex:

            function buttons_clicked(evt_obj)
            {
            trace ("seventyButtons_clicked()")
            trace ("evt_obj.target:" + evt_obj.target._name )
            switch(evt_obj.target)
            {
            case one_button:
            // do something
            break;
            case two_button:
            // do something
            break;
            case three_button:
            // do something
            break;

            }

            }
            one_button.addEventListener("click", buttons_clicked);
            two_button.addEventListener("click", buttons_clicked);
            three_button.addEventListener("click", buttons_clicked);

            With custom buttons you have a programmers choice on how to do it. Here is
            one basic way

            one_btn.onRelease = two_btn.onRelease = three_btn.onRelease = function()
            {

            trace(this)
            switch (this)
            {
            case _level0.one_btn:
            // do something
            break;
            case _level0.two_btn:
            // do something
            break;
            case _level0.three_btn:
            // do something
            break;


            }


            }



            --
            Lon Hosford
            www.lonhosford.com
            May many happy bits flow your way!
            "matecito" <webforumsuser@macromedia.com> wrote in message
            news:e2urkb$p7b$1@forums.macromedia.com...
            I have about 70 buttons on a page - and I want all of them to get the same
            eventlistener... can I add it to all of them with one fell swoop?