2 Replies Latest reply on May 4, 2006 10:28 AM by Newsgroup_User

    stuck on a scrolling script

    macron Level 1
      hi,

      i'm trying to write a script that scrolls a movie clip up or down, and stops the scrolling when the top or bottom of the movie clip reach the appropriate part of the viewing pane, regardless of the height of the movie clip.

      the viewing pane is 300px high, and the movie clip is of variable height of course.

      _y of the movie clip always starts at 9.4, so the script for limiting the downward movement of the clip is:

      if(this.down==true and _y<9.4)
      this._y+=8;

      i would have thought that the script for limiting the upward scrolling of the clip would be

      if(this.up==true and _y>-(this.height-300))
      this._y-=8;

      but when i click on the scroll up button, nothing happens.

      i'm stumped. is my math bad, or is my syntax wrong?

      cheers,
      macron
        • 1. Re: stuck on a scrolling script
          kglad Adobe Community Professional & MVP
          you probably have a logic problem. my guess is your movieclip is going to move to a position that puts it out of range for both those conditions on this._y. to check, use trace(this._y).
          • 2. Re: stuck on a scrolling script
            Level 7
            The code actually looks OK, except I think you should always be explicit -
            using _y in your if condition and then this_y immediately after is just
            confusing. Other than that it's likely what kglad said and you're getting
            into a bad range - probably due to rounding errors since you're using a
            fractional number, 9.4, to start.
            If you do a little test and subtract 8 from 9.4, say 20 times, and then add
            it back you come out to something like 9.400001 - not just 9.4...
            So, you should always check your limits like so:

            if(this.down && this._y + 8 < 9.4)
            this._y+=8;
            }else{
            this._y = 9.4;
            }

            and is deprecated - use && instead


            --
            Dave -
            Adobe Community Expert
            www.blurredistinction.com
            www.macromedia.com/support/forums/team_macromedia/