Creating a non-component flash book turning Effect

Source: Internet
Author: User

Creating a non-component flash book turning Effect
Author: tiger_0309 | Source: Flash
There are a lot of such things on the internet, but most of them are made of components, and some are often charged. I don't need this component, basically it is Code But the structure is simple and clear at a glance. You can see it by downloading the original file. I will not elaborate on the meaning of the Code, here I will mainly explain how to rewrite the code when replacing my own images.
The home scene has a total of four frames of code:
Code of the first frame: X1 = 50; Y1 = 50
X2 = 250; y2 = 50
X3 = 450; Y3 = 50
X4 = 50; Y4 = 200.
X5 = 250; Y5 = 200
X6 = 450; y6 = 200
// The six coordinate points are the upper left, upper right, upper left, lower left, middle right, and lower right of the book. The upper left (x1, Y1) is the positioning point, you can decide on the position of the stage, and then the remaining five coordinates are determined by the size of your picture, (x2-x1) and (x3-x2) are equal to the book's single page width, the same way (x5-x4) and (x6-x5) is equal to the same principle, (y4-y1) and (y5-y2) and (y6-y3) is equal to the height of the picture.
Attachmovie ("cover", "P0", 100)
// This is the first one
Attachmovie ("bottom", "P19", 120)
// This is the last one
For (I = 2; I <= 20; I + = 2 ){
Attachmovie ("page" + I, "P" + I, 100 + I/2)
}
// 17 is the total number of images 20-3.
For (I = 1; I <= 17; I + = 2 ){
// The value of 111 is calculated based on the level of page20 being 110.
Attachmovie ("page" + I, "P" + I, 111 + (I-1)/2)
}
// The number of your images is different, and the level of each image is also important. You need to adjust it based on the number of images in my original file and your comparison.
// Images are called from the library, so they must have a link identifier. You must edit all the images into a video clip, in each video clip, align the left and bottom of the image to the stage. This is very important, and the image you want to prepare must be double-digit.
// In the video clip page20, draw a rectangle of the same size as the image. The color is the same as that of the background color, and it must be left aligned and aligned to the stage.
Mask1. _ x = X6;
Mask1. _ y = 0
Mask2. _ x = X6
Mask2. _ y = 0
// Try to make the mask bigger, half of which are used in the main scenario
Mask1. _ visible = false
Mask2. _ visible = false
Page = 0
Mouse2 = 0
X = X6
Y = y6
Xmouse = X6
Ymouse = y6 second frame code:
Flag = 1
If (page> 0 ){
Eval ("p" + (page-1). _ visible = true
Eval ("p" + (page-1). _ x = X4
Eval ("p" + (page-1). _ y = Y4
Eval ("p" + (page-1). _ rotation = 0
}
// 20 is the image number I used.
If (page <20 ){
Eval ("p" + page). _ visible = true
Eval ("p" + page). _ x = X5
Eval ("p" + page). _ y = Y5
Eval ("p" + page). _ rotation = 0
Eval ("p" + (page + 1). _ visible = true
Eval ("p" + (page + 1). _ x = X6
Eval ("p" + (page + 1). _ y = y6
Eval ("p" + (page + 1). _ rotation = 0
Eval ("p" + (page + 1). setmask (mask1)
Eval ("p" + (page + 2). _ visible = true
Eval ("p" + (page + 2). _ x = X5
Eval ("p" + (page + 2). _ y = Y5
Eval ("p" + (page + 2). _ rotation = 0
Eval ("p" + (page + 2). setmask (mask2)
}
// This should also be changed
For (I = 0; I <= 20; I ++ ){
If (I <page-1 | I> page + 2 ){
Eval ("p" + I). _ visible = false
}
} Third frame code:
Xx = _ xmouse
YY = _ ymouse
If (key. isdown (1 )){
Mouse1 = 1
}
Else {
Mouse1 = 0
}
If (mouse2 = 1 & mouse1 = 1 & (xx-x5) * (xx-x5) + (yy-y5) * (yy-y5) <= (x6-x5) * (x6-x5 )) & (xx-x2) * (xx-x2) + (yy-y2) * (yy-y2) <= (x6-x5) * (x6-x5) + (y5-y2) * (y5-y2 ))){
Xmouse = xx
Ymouse = YY
}
If (mouse2 = 0 & mouse1 = 1 ){
// 150 is about half the width of the main scenario. Its value determines the sensitivity of your mouse. You can adjust it according to your scenario.
If (flag = 1 & XX <150 & page> 0 ){
Page-= 2
X = X4
Y = Y4
Xmouse = X4
Ymouse = X4
Gotoandplay (2)
}
}
If (mouse1 = 1 ){
Flag = 0
X = xmouse/5 + x * 4/5
Y = ymouse/5 + y * 4/5
}
If (mouse1 = 0 ){
// Change the value of 150, as shown in the preceding figure.
If (xmouse> 150 ){
X = X6/6 + x * 5/6
Y = y6/4 + y * 3/4
}
Else {
X = X4/6 + x * 5/6
Y = Y4/6 + y * 5/6
}
}

eval ("p" + (page + 1 )). _ x = x
eval ("p" + (page + 1 )). _ y = Y
If (flag = 0 & page <20 & math. ABS (x-x4) + math. ABS (y-y4) <1) {
page + = 2
X = X6
Y = y6
xmouse = X6
ymouse = y6
flag = 1
gotoandplay (2)
}< br> If (math. ABS (x-x6) + math. ABS (y-y6) <0.5) {
A = 0
flag = 1
}< br> else {
A = math. atan2 (y6-y, x6-x)
}< br> eval ("p" + (page + 1 )). _ rotation = 2 * a * 180/math. pI
mask1. _ x = (x + X6)/2
mask1. _ y = (Y + y6) /2
mask1. _ rotation = A * 180/math. pI
mask2. _ x = (x + X6)/2
mask2. _ y = (Y + y6) /2
mask2. _ rotation = A * 180/math. pI
mouse2 = mouse1
fourth frame code:
gotoandplay (3); download: Book 2. rar attachment: Book 2. SWF

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.