0 Replies Latest reply on Jun 2, 2007 6:48 AM by Newsgroup_User

    AS 2 Delegate

    Level 7

      Hi, a question.
      I'm talking about AS 2.

      In a class I've:

      btnCollection.onRollOver = function() {
      // this._name is a button name
      var t = Number(this._name.substr(1, 1));
      //
      Mouse.hide();
      // cRef is a reference to the class
      cRef.cursor._visible = true;
      startDrag(cRef.cursor, true);
      //
      cRef.setRotation(cRef.curPos[t]);
      };

      btnCollection is previously created, this way:

      for (i=0; i<btns; i++) {
      var btnCollection = targetLevel['c'+i+'_btn'];
      }

      cRef is previously created this way:
      var cRef = this; // it stores a reference to the class.

      the var t registers a number contained in a button name (I use that
      number to perform various tasks).

      This is perfectly working, but now I want to use the Delegate class.

      So, I did the following:

      btnCollection.onRollOver = Delegate.create(this,
      btnRollOver(btnCollection));

      after having built this method:

      private function btnRollOver(whichBtn) {
      var t = Number(whichBtn._name.substr(1, 1));
      //
      Mouse.hide();
      //
      cursor._visible = true;
      startDrag(cursor, true);
      //
      setRotation(curPos[t]);
      }

      nothing works like before.

      That is: I probably easily get the class reference but I've lost the
      reference to the single button...

      Please, can you help me better understand (and solve) this issue?

      Thanks!