Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2010
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question Multiple variables on one event?

    I want a way to apply a mouse event to multiple button/instance names. Here is the two events that will do the same thing:

    Code:
    image1.addEventListener(MouseEvent.CLICK, shift);
    next2.addEventListener(MouseEvent.CLICK, shift);
    Is there anyway to make this into one statement?

  • #2
    Regular Coder
    Join Date
    Nov 2009
    Location
    Scotland / Glasgow
    Posts
    184
    Thanks
    1
    Thanked 19 Times in 19 Posts
    The adding of events needs to be added to each object but when listening for the event firing you can have one function that handles all the events that where added.
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    62
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Its also possible to create an Array in your object. But you have to write a small class for it.

    Because you can't overwrite a named listener so easy.
    But you can use an object in an object (Objectcontainer). So you're able to add as much behaviors as you want to that listener


  •  

    Tags for this Thread

    Posting Permissions

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