The script runs again when you release and press the scroll button again. This time the "if" argument can't be evaluated to a null, since we have a definite value (5000) stored in the up_last_click variable. Lets assume you pressed the button exactly one quarter (1/4) second after the first press, and lets step through this script again:
up_first_click = getTimer( );
Now the up_first_click variable is updated to a new value by the "getTImer" action. Since one quarter second translates to 250 ms, up_first_click's new value will be 5250 (5000 + 250 = 5250). With that done, we move to the "if" condition, and fill in our numeric values for the up_first_click and up_last_click variables. 5250 - 5000 = 250 ms. Using this inequality expression, Mick has set the double-click threshold to 350 ms. As long as the pause between button presses is equal to or less than 350 ms, as it is in our example, the "if" argument returns "true" and its embedded action is executed. If the pause between cicks is longer than 350 ms, the continuous feedback buttons are triggered instead.
The embedded action, "scroll_shape._y = scroll_shape.logic.top;" immediately sets the _y position of scroll_shape to its uppermost limit, top. This is what creates the jump effect. Since our example "if" argument returns "true," the continuous feedback action embedded within the "else" clause is skipped. (A "true" value for the "if" statement voids the "else" clause below it.) Either way though, the action loop in logic is always triggered on (press) because the "gotoAndPlay("scroll_logic")" action isn't embedded within either the "if" or the "else." Conversely, logic is always stopped on (release).
The script for the bottom button is again structured very similarly to the
top, however the double click variables are named down_first_click and
down_last_click. Also the jump action embedded within the "if"
statement sets scroll_shape._y
to bottom, not top. The code in the source FLA is extensively
commented, but feel free to remove the comments ("//blah
blah blah") if it makes the code easier to understand for you :^)
|» Level Intermediate|
Rating: 8 Votes: 94
|Me Like Flash 5. Flash 4 good. Flash 5 better.|
|Download the files used in this tutorial.|
|Download (229 kb)|
|More help? Search our boards for quick answers!|