flasheventsactionscript-2adobe-flash-cs3

determining event.target in as2


How to detect on which movieClip an event has fired in as2. I have made a list of duplicate movieclips and want to add click event on each movieclip and distinguish on which movieclip event has fird. I know the solution in as3 but need as2 solution for it. Please, help.


Solution

  • In AS2, when you assigned a function say using myButton.onRelease = myFunction;, within the function you can reference the caller simply using this:

    function myFunction() {
     trace(this._name);
    }
    
    myButton.onRelease = myFunction; // will trace "myButton" when you click it