2 Replies Latest reply on Jun 13, 2006 4:54 AM by Newsgroup_User

    passing function name into another function?

    Level 7
      Hi

      I have a movieclip prototype thats scales and moves any movieclips depending
      on the parameters passed in. I want to be able to pass in a function name
      that is executed when the main function has finished. The problem is the
      line of code that calls the main function executes the function name that I
      m trying to pass in as a parameter. Is there something I m missing?

      see my code below:

      "mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y, -100,
      mcMainAnimation._xscale, -30, 50,moveToX());"

      MovieClip.prototype.moveFadeTransform = function(t, oldY, diffY, oldScale,
      newScale, tTime, funcToCall) {
      this.onEnterFrame = function() {
      t++;
      if (t<=tTime) {
      this._y = easeIn(t, oldY, diffY, tTime);
      this._xscale = easeIn(t, oldScale, newScale, tTime);
      this._yscale = easeIn(t, oldScale, newScale, tTime);
      } else {
      t = 0;
      funcToCall;
      this.onEnterFrame = null;
      }
      };
      };

      moveToX = function () {
      trace("called");
      }


      Thank in advance

      Shaun


        • 1. Re: passing function name into another function?
          Level 7
          Hi!

          Try to modify code to:
          mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y, -100,
          mcMainAnimation._xscale, -30, 50,moveToX);"

          ... so don't use () at end of function. That should do the trick.

          Also, you need to add the () to funcToCall, so that instead of:

          t = 0;
          funcToCall;
          this.onEnterFrame = null;

          you should have
          t = 0;
          funcToCall();
          this.onEnterFrame = null;

          /Jensen/

          "forums.macromedia.com" <shaun@thetouchagency.co.uk> wrote in message
          news:e6m428$qa0$1@forums.macromedia.com...
          > Hi
          >
          > I have a movieclip prototype thats scales and moves any movieclips
          > depending on the parameters passed in. I want to be able to pass in a
          > function name that is executed when the main function has finished. The
          > problem is the line of code that calls the main function executes the
          > function name that I m trying to pass in as a parameter. Is there
          > something I m missing?
          >
          > see my code below:
          >
          > "mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y, -100,
          > mcMainAnimation._xscale, -30, 50,moveToX());"
          >
          > MovieClip.prototype.moveFadeTransform = function(t, oldY, diffY, oldScale,
          > newScale, tTime, funcToCall) {
          > this.onEnterFrame = function() {
          > t++;
          > if (t<=tTime) {
          > this._y = easeIn(t, oldY, diffY, tTime);
          > this._xscale = easeIn(t, oldScale, newScale, tTime);
          > this._yscale = easeIn(t, oldScale, newScale, tTime);
          > } else {
          > t = 0;
          > funcToCall;
          > this.onEnterFrame = null;
          > }
          > };
          > };
          >
          > moveToX = function () {
          > trace("called");
          > }
          >
          >
          > Thank in advance
          >
          > Shaun
          >


          • 2. Re: passing function name into another function?
            Level 7
            Try this:


            mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y, -100,
            MainAnimation._xscale, -30, 50,"moveToX");"

            MovieClip.prototype.moveFadeTransform = function(t, oldY, diffY, oldScale,
            newScale, tTime, funcToCall) {
            this.onEnterFrame = function() {
            t++;
            if (t<=tTime) {
            this._y = easeIn(t, oldY, diffY, tTime);
            this._xscale = easeIn(t, oldScale, newScale, tTime);
            this._yscale = easeIn(t, oldScale, newScale, tTime);
            } else {
            t = 0;
            this[funcToCall]();
            this.onEnterFrame = null;
            }
            };
            };

            moveToX = function () {
            trace("called");
            }


            --
            -------------------------------
            Remove '_spamkiller_' to mail
            -------------------------------