FLASHMX2004 make buffering scroll bar effect

Source: Internet
Author: User
Tags constant range

One, Effect preview

Ii. Establishment of objects

Three, fill in as

Four, as detailed

Frame 1th:

Show_scroll.onpress=function ()           ///scroll bar is pressed down the lock is opened  show_scroll.onrelease=function ()//scroll bar is relaxed  lock is closed Show_ Scrollbg.onpress=function ()///scroll bar blank area is clicked   the lock is opened show_scrollbg.onmouseup=function ()//mouse hoist   lock is closed//There is a reason for this. When you click the mouse to release when not in the scroll bar background SCROLLBG//lock will never close, the whole picture will be slowly flowing with the mouse on your monitor

Frame 2nd:

if (scroll_lock== "no") {  show_scroll._y+= (_ymouse-show_scroll._y-15)/2}show_image._y+= (-(show_image._ HEIGHT-300) * (show_scroll._y*300/270)/300-show_image._y)/20

Detailed Explanation:

show_scroll._y+= (_ymouse-show_scroll._y-)/2: Where "15" represents half the length of the scroll bar, "2" represents the scrollbar buffer constant, note: This constant is not set too large, Lest the mouse down, the scroll bar is still on top.

show_image._y+= (-(show_image._height-300) * (show_scroll._y/270)-show_image._y)/20:show_image._y+= (-(show_image). _height-[the height of the scrolling display area]) * (show_scroll._y/[scrolling height of the display area-scroll bar height])-show_image._y)/[is scrolling the movie buffer constant, do not set too large in order to avoid the mouse down the scroll bar is still above]

Let's start by holding down the scroll bar. When unlocked, that is, when the scroll bar scroll or the background SCROLLBG is pressed, the show_scroll._y is the vertical position of the scroll bar, the buffer moves to the 15 pixels in the current position of the mouse, and then the scrolling film moves to a specified position with buffering.

The main place came: the show_image._height-300 meaning is half the length of the _ymouse-show_scroll._y-[scroll bar],show_image The maximum range to be moved. The following is the ratio of the total scrolling position to where the show_image scroll, and the ratio of Y to the total moving range of the scroll bar. So with the show_image+= ([limit position]-show_image._y)/20 This is a buffered algorithm, each loop to the limit to the current distance of 1/20 near.

[Limit position] =-(show_image._height-300) * (show_scroll._y/270), (show_scroll._y/270) is the ratio of the _y of the scroll bar to the rolling range

Then the show_image._height-300 multiplication (show_scroll._y/270) is used to get the show_image, which is the same as the ratio of the total rolling ratio and the scroll bar to the total rolling range. The _y value is preceded by the "-" sign to reach the scroll bar downward and is scrolled up by the effect of the MC. Then when you click on the scroll bar, you can move the range blank, the lock opens, gets the current position of the mouse, the scroll bar immediately buffers to move to this position, and then, like dragging the scroll bar to move down the steps.

Legend:

source File Download



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.