1 Reply Latest reply on Jul 12, 2006 8:01 AM by Newsgroup_User

    Static function on movie clip

      Hi all!

      I would like to have a static function associated with a button, so all instances of the said button would behave the same way when rolled over, but differently when clicked.

      Let's say I have a MC called myButton with 2 instances called a_btn and b_btn.

      I'd like both buttons to have a different behaviour when clicked:

      a_btn.onPress = function():Void {
      // do some A stuff

      b_btn.onPress = function():Void {
      // do some B stuff

      However, I'd like both (and any other instances of myButton) to have the same behaviour when rolled over. I tried something like:

      myButton.onRollOver = function():Void {
      // do common thing

      but that didn't seem to work.

      would anybody know how to do this?

        • 1. Re: Static function on movie clip
          Level 7
          If you have your buttons as movieClips then you could make a class that
          extends movieClip with just your rollOver functionality in it, then assign
          custom functions to the onRelease handlers for each button individually. And
          FWIW, you should use onRelease instead of onPress as it's a standard. If you
          have special need for onPress then fine, but no buttons in your OS or
          regular applications work with click... they all work on release.

          Dave -
          Adobe Community Expert