1 Reply Latest reply on Apr 21, 2006 2:51 AM by blemmo

    Overriding event handlers

    DaveBar
      newbie to OO and Flash here, so hope not a stupid question!

      1. Have created a class that extends MovieClip. The class includes some code for the OnRelease event handler.
      2. Create and display new instance - OnRelease event in class works fine.
      3. Add to the created instance a new OnRelease handler - it works but the OnRelease code in the class is no longer called

      Is there a way to get both the have the OnRelease code within the instance and within the class execute?

      My workaround at the moment is to have an event defined in the class called "onWhatever", which i then call from the OnRelease when i instatiate the movieclip. This seems a inefficient to me and i would have thought a better way would exist?

      Cheers, David
        • 1. Re: Overriding event handlers
          blemmo Level 1
          Hi,

          I think if you assign an onRelease event to the instance, it overwrites the event defined in the class. Your workaround isn't bad, in fact it is more logical than assigning an onRelease event to the instance but having the class event execute too. I would use this workaround.
          You could try to call super.onRelease in the event assigned to the instance, but I guess this calls MovieClip.onRelease, which isn't defined. You could extend your class again and call super.onRelease from this new class, then it should call the event declared in the first extended class. But again, calling the onWhatever seems more practical to me.

          hth,
          blemmo