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)
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))
but when i click on the scroll up button, nothing happens.
i'm stumped. is my math bad, or is my syntax wrong?
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
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
So, you should always check your limits like so: