4 Replies Latest reply on May 31, 2007 10:03 AM by kglad

    Simulate an Event

    smazr123 Level 1
      Is there a way to get an event to run from actionscript? For example if I have a Mouse CLICK event registered with a movie, and I want it to be run. I know I can just call the function that the event calls, but I cant pass the event object.
        • 1. Re: Simulate an Event
          Rothrock Level 5
          Why not? All you need to do is make your own. The MouseEvent class has its own constructor. Just look it up. You will see it shows you all the default values as well so you can either assign the ones you want or use the default values. The code below is pretty basic, but it does what you need.

          You could probably also assign the myEvent as the default value for the event handler function and avoid having to remember to send it. I haven't tried that yet.
          • 2. Re: Simulate an Event
            Rothrock Level 5
            Well no, evidently you can't assign it as the default value for the function, but it does work in the form above.
            • 3. Re: Simulate an Event
              smazr123 Level 1
              The function that my mouse CLICK calls uses the currentTarget property to determine what action it should take. So I tried making my own MouseEvent and setting the relatedObject Paramiter to the object that I wanted the currentTarget property to respond to. This didnt work??? Isn't there a way to set what the currentTarget is going to be?
              • 4. Re: Simulate an Event
                kglad Adobe Community Professional & MVP
                currentTarget is read-only.

                use an if-statement in your event handler to check if currentTarget is null.