1 Reply Latest reply on Oct 1, 2008 2:36 PM by Newsgroup_User

    Event Handlers which trigger functions with multiple arguments

    muskiemania
      I am playing two video clips back to back. I have a few things which I need to do in between clips, so what I am doing for each is adding a handler for VideoEvent.COMPLETE, at which time i want to call a function which takes multiple arguments, like this:

      video.addEventListener(VideoEvent.COMPLETE, myFunction("1","2","3"));

      private function myFunction(var1:String, var2:String, var3:String):void
      {
      video.removeEventListeners(VideoEvent.COMPLETE, myFunction);
      }

      I've already figured out that getting rid of event handlers that trigger anonymous functions is impossible. Please don't tell me that it's impossible to remove them if functions require more than 0 arguments...
        • 1. Re: Event Handlers which trigger functions with multiple arguments
          Level 7

          "muskiemania" <webforumsuser@macromedia.com> wrote in message
          news:gc0pk0$jfb$1@forums.macromedia.com...
          >I am playing two video clips back to back. I have a few things which I need
          >to
          > do in between clips, so what I am doing for each is adding a handler for
          > VideoEvent.COMPLETE, at which time i want to call a function which takes
          > multiple arguments, like this:
          >
          > video.addEventListener(VideoEvent.COMPLETE, myFunction("1","2","3"));
          >
          > private function myFunction(var1:String, var2:String, var3:String):void
          > {
          > video.removeEventListeners(VideoEvent.COMPLETE, myFunction);
          > }
          >
          > I've already figured out that getting rid of event handlers that trigger
          > anonymous functions is impossible. Please don't tell me that it's
          > impossible to
          > remove them if functions require more than 0 arguments...

          Any function that you add via addEventListener should expect exactly ONE
          argument, the event. And 99.958% of the time, you can take that event
          object and figure out exactly what you need to know.

          HTH;

          Amy