A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: one listener, many buttons. Is it possible?

  1. #1
    Senior Member martin47's Avatar
    Join Date
    Dec 2000
    Posts
    413

    Lightbulb one listener, many buttons. Is it possible?

    I have many buttons on screen. About 25. They are all different shapes. Is there a way to have a listener that can inform me the _name of the button clicked when any of them is clicked? Thanks ahead for any help.
    http://www.drakon.com.ar

  2. #2
    Island Boy
    Join Date
    Apr 2006
    Posts
    655
    you can do this in actionscript with variable passing. each button thas tis clicked passes itself into a function that gets the button name(providing you give it an instance name) and does whatever you want to do with it.


    Code:
    myButton_btn.onRelease = function(){
         getName(this);
    }
    
    
    function getName(button){
         trace(eval(button)._name);
    }
    Last edited by VI Knight; 08-24-2006 at 06:38 PM.

  3. #3
    Senior Member martin47's Avatar
    Join Date
    Dec 2000
    Posts
    413
    Thanks Knight, I´ll try that, sounds like a great solution!
    http://www.drakon.com.ar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center