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));
      // cRef is a reference to the class
      cRef.cursor._visible = true;
      startDrag(cRef.cursor, true);

      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,

      after having built this method:

      private function btnRollOver(whichBtn) {
      var t = Number(whichBtn._name.substr(1, 1));
      cursor._visible = true;
      startDrag(cursor, true);

      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?