0 Replies Latest reply on Jan 10, 2007 6:11 AM by Newsgroup_User

    setInterval passing variables...Need help

    Level 7
      I have a script that I am trying to use the setInterval command to animate a
      textfield on the stage. I have a sample script that works and passes the
      value of this._y to the fly function but it uses onEnterFrame since it is
      created using movie clips in the library rather then in a action script
      class file. Any thoughts would be GREAT! its my understanding that the
      .prototype method indicates that the new function will assume all values of
      the previous function... is that not correct?

      +++++++++++++++++++++++++++++++++++++++
      New Code:
      +++++++++++++++++++++++++++++++++++++++

      function ScrollMsg(nin, depth, initialization) {
      this._x = 30;
      this._y = 500;
      this.createTextField("Msg", 0, 0, 0,500, 150);
      with(initialization.msgtext) {
      wordWrap = true;
      multiline = true;
      border = true;
      text = initialization.msgtext;
      trace("bfr-this._y:"+this._y); // has value of _y
      = to 500
      }

      }
      // set continual function to fly
      ScrollMsg.prototype.fly = function() {
      trace("this._y:"+this._y); // value is
      undefined

      if (this._y > initialization.distance) {
      this._y -=_global.MSG_SPEED;
      trace("--this._y:"+this._y); // value is
      undefined
      } else {
      this.removeMovieClip();
      }

      };
      //Define Speed
      setInterval( ScrollMsg.prototype.fly , 1000 );

      +++++++++++++++++++++++++++++++++++++++
      Original Script: (Works perfectly)
      +++++++++++++++++++++++++++++++++++++++

      // allow ScrollMsg to inherit MovieClip properties
      ScrollMsg.prototype = new MovieClip();

      function ScrollMsg() {
      this._x = 30;
      this._y = 0;
      this.createTextField("Msg", 0, 0, 0, this.msgwidth, 10);
      with(this.Msg) {
      setNewTextFormat(_global.MsgFormat);
      autoSize = "left";
      wordWrap = true;
      multiline = true;
      embedFonts = true;
      selectable = false;
      text = this.msgtext;
      }
      // set continual function to fly
      this.onEnterFrame = this.fly;

      }

      // instance methods
      ScrollMsg.prototype.fly = function() {
      if(!_global.MSG_ON_HOLD&&!_global.SYSTEM_ON_HOLD) {
      if (this._y > this.distance) { this._y -=_global.MSG_SPEED;} else {
      this.removeMovieClip(); }
      //this._alpha = 100 - Math.abs(this._y - this.distance/2)*.3;
      }

      };