Continuous scrolling effect of picture groups

Source: Internet
Author: User
Now on the Web page often see the continuous scrolling effect of the group, if you have mastered as the basic knowledge, can make such an effect, if you want to learn, then follow me!

Because there is only one frame in the source code, so do not stick to the diagram. The main dongdong is a picture MC, the instance name is "M". This is how the process is made. First of all, the combination of a group, the relative stage selection level and vertical center, and then copy two picture combinations, respectively, on both sides of the link. Create a new MC, the image MC (instance name "M") put in, relative stage selection horizontal and vertical center, do not do other processing. Give this MC an instance called "MC".
The next step is to write the code and add the following code to the clip on the instance named "MC":
If you are an old bird, you will understand it again; If you are a rookie, here are the following lines of explanations:
Onclipevent (enterframe) {
This.m._x + + = (_root._xmouse-275)/10;
_ROOT.AA = Int (this.m._x);
if (this.m._x>862.4) {
this.m._x = this.m._x-862.4;
}
if (this.m._x<-862.4) {
this.m._x = this.m._x+862.4;
}
}
Onclipevent (enterframe) {
Ty=this._yscale;
newy=ty+ (_root._ymouse-200)/30;
if (newy>150) {
newy=150;
}
if (newy<80) {
newy=80;
}
This._xscale=newy;
This._yscale=newy;
}
//*----------------------------------
Onclipevent (enterframe) {
this.m._x = = (_root._xmouse-275)/10;//because the scene is 550, so the center is 275, the X coordinate of instance m accumulator (_root._xmouse-275)/10; When the mouse is on the right side of the center (_root._ xmouse-275)/10 is a positive value, so scroll to the right, and if = = to be the mouse on the right, scroll to the left.
_ROOT.AA = Int (this.m._x);//test used, my habit.
if (this.m._x>862.4) {
this.m._x = this.m._x-862.4;//862.4 is the width of a picture group in instance M. If the value is greater than this, the instance m has moved the length of a picture group, allowing the this.m._x to subtract 862.4, which is equivalent to returning to the original position, to achieve circular scrolling.
}
if (this.m._x<-862.4) {
this.m._x = this.m._x+862.4;//General explanation refer to the above
}
}
//*---------------------------
Onclipevent (enterframe) {
ty=this._yscale;//to obtain the Y-directional proportional value of MC in instance
newy=ty+ (_root._ymouse-200)/30;//because the scene height is 400, so the center is 200; When the mouse is over the center, zoom out and zoom in when the mouse is below the center.
if (newy>150) {
newy=150;//can not be enlarged infinitely, to limit the
}
if (newy<80) {
newy=80;//ditto
}
this._xscale=newy;//x direction Proportional value
this._yscale=newy;//y-Directional proportional value
}
Do you want to sum it up? I think the main technology lies in the MC of the nesting, the internal MC do scrolling, it itself to do scaling, not affect, this should be the key technology of this example. As for the base, it is the variables, the assignment, the judgment condition and so on. To add, if you want to shrink the proportion of <80, you may encounter problems, because you shrink may not be enough length, inconsistent. At this point you can add two pictures on both sides of the three photos group, the corresponding this.m._x = this.m._x-862.4 changed to this.m._x = This.m._x-2*862.4,this.m._x = this.m._x+ 862.4 change into this.m._x = this.m._x+2*862.4, it should be done. This is another feature of this example: scalability. If you can't understand, I'll draw a schematic:

Download Source Files

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.