3 Replies Latest reply on Oct 2, 2007 12:45 AM by kittuokkade

    passing parameters to event triggered functions

    kittuokkade Level 1
      hi all,
      i have created a button and added EventListener.
      as mybutton.addEventListener(MouseEvent.CLICK,clickSt art);
      when i implement the clickStart (event:MouseEvent) function i want to pass
      an array ,a String to this function as parameters .how can i do this.
      is it possible or not.

        • 1. Re: passing parameters to event triggered functions
          Depends if the array is public or private...in the scope of the function . For example, in some applications, i will have a "container" array. This is declared before the actual constructor

          public var containerArray:Array= new Array()

          then you can access that array from any event handlers, etc. The danger of course is if you are playing with these variables a lot, or quickly, you loose flexibility. Another option, is to creat the variables in a class, and create instances of the class to be accessed later.
          • 2. Re: passing parameters to event triggered functions
            _Albertx_ Level 1
            Well, not in that way.
            The function automatically receives a parameter when you create a callback with that function by "addEventListener", such parameter is datatyped as the event type you defined in the callback, in your case "MouseEvent". If you want to pass more data when the function is called then you have to create your own event class because almost all events just inform when something has happened and send limited information. You can check the documentation about creating a custom event class, there is a lot of info about the topic.