Flash as Create picture scrolling effect

Source: Internet
Author: User

When we browse the Web , we often see a variety of pictures scrolling menu, banners and ads, although the effect is basically the same, but because the writer's ideas vary, so the complexity of the script is very different, here is a very simple script example.
Basic ideas

① at the center of the MC of the left and right sides, while placing the same set of pictures, the center point is also the beginning and end phase

② measured the distance between the mouse and the horizontal center point of the scene, and judged the MC to the left or right and how fast it was moving.

③ when the MC left to the left side of the scene or the right side of the MC, the MC returns to a certain position to achieve continuous cyclic scrolling.

New Knowledge points
stage.width//the width of the scene, is random teacher taught me, I find half a day did not find.

stage.height//the height of the scene, practice to use.

Moviecl the width of theIP. _width//mc.

Movieclip._height//MC height.

Example description

① in the MC registration points are placed in the same group of pictures, in the home scene if the MC movement to the edge of the moment, that is, by the center point of substitution, when playing the film to see the picture is consistent, but not the end, will form the effect of looping playback.

② get the scene and the width of the MC, in order to calculate the comparison, with the mouse deviation from the scene horizontal line of the distance for the MC moving parameters, when the mouse is the wire, the value of 0, the MC static, distance large movement speed is fast.

③ Set 2 conditions to judge, is in the MC movement to the edge, reposition.

Writing Action Scripts

① Enter on frame 1th:

m=stage.width;//Gets the width of the scene
n=tu._width/2;//gets the value of 1/2 of the width of the MC
tu._x = tu._x-(m/2-_xmouse)/10;//the mouse with the horizontal centerline 1/10 of the difference is added to the position of the MC, which is then assigned to the new MC position.   
② input on frame 2nd:
if (tu._x>=n) {//MC left to the left of the scene
Tu._x = TU._X-N;//MC relocate to its own center point at the left end of the scene
}
if (tu._x<= (m-n)) {//MC to the right side of the scene at the right end of the
tu._x = tu._x+n;//MC relocate to its own center point on the right side of the scene

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.