The production of mosaic effect

Source: Internet
Author: User
Tags empty reference
The techniques you can learn include: copying statements and removing the statements of the duplicated MC, the flexible application of random numbers, the use of for statements, simple array applications, judgment statements, and so on.
The first step: first look at its structure: reference diagram (1): The first layer of background, put the PLMM; the second layer of gray block, put is a mosaic of a component; The third empty as, put is a blank MC, the instance name is "as", inside all is the As command, the fourth layer B and Wen, put is the button and the dynamic text box.

Step two: First to make a square, with a width of 20 pixels, grayscale #999999, converted to symbols; then make an animated clip symbol, put the square in, insert keyframes in frame 6th, reference figure (2): Adjust transparency to 30, insert keyframes at frame 7th, so that the 7th frame is the same as the contents of the 6th frame, Then insert a keyframe in the 12th and paste the first frame into frame 12th. So frames 1th and 12th are gray blocks with a transparency of 100, and the move gradient animation is set. After doing well, give it an instance named "MC";

The third step: to achieve the random play of gray blocks, in the gray Block instance "MC" bundle the following code:
Onclipevent (load) {//animated load
Num=random (12) +1;//let num take a random value between 1~12
This.gotoandplay (num);/This refers to the call to itself, allowing this MC to play the number of random frames obtained.
}
The fourth step: to make that empty MC, instance named "as", a new MC, write the following code on the first frame:
Stop ();
_root.mc._visible=0;
mcw=20;
For (i=0 i<12; i++) {
For (j=0 j<10; j + +) {
Duplicatemovieclip ("_ROOT.MC", "MC" +i+j, 10*i+j);
_root["mc" +i+j]._x = Mcw*i;
_root["mc" +i+j]._x = Mcw*j; }
}
//***********
(see below for a step-by-step explanation, please.) )
Stop ();
_root.mc._visible=0;
mcw=20;
The width of the square.
For (i=0 i<12; i++) {
The loop produces 12 numbers. 0~11
For (j=0 j<10; j + +) {
The loop produces 10 numbers. 0~9:120 bucks for a ride.
Duplicatemovieclip ("_ROOT.MC", "MC" +i+j, 10*i+j); Pay attention to depth
Copy should all know.
_root["mc" +i+j]._x = mcw*i;//use an array to store the duplicated MC names, plus the path
The first loop is copied out for MC00, 01, 02, 03 ...; The corresponding x coordinates are 0
The second loop is copied for MC10, 11, 12, 13 ...; The corresponding x coordinates are 20*1=20
// ......
_root["mc" +i+j]._y = Mcw*j;
The first loop is copied out for MC00, 01, 02, 03 ...; The corresponding y coordinates are 0, 20, 40, 60
The second loop is copied for MC10, 11, 12, 13 ...; The corresponding y coordinates are 0, 20, 40, 60
// ......
}
The first loop is copied out for MC00, 01, 02, 03 ...; The corresponding coordinates are (0, 0) (0, 20) (0, 40) ...
The second loop is copied for MC10, 11, 12, 13 ...; The corresponding coordinates are (20, 0) (20, 20) (20, 40) ...
As you can see, it is a set of columns in the vertical column.
}
*——————————
Then write the code on the second frame: Stop ();
The fifth step: the production here, you can test, the effect is good! I've added a little bit of functionality. The Code on the button you see, the code is as follows:
On (release) {
agg = agg+1;
if (agg%2) {//Judge odd even number, if odd, stop in second frame; If an even number, stop at the first frame
As.gotoandstop (2);
_root.wen= "Keep flashing, hazy feeling better";//Text displayed
For (i=0 i<12; i++) {//Only set a loop, or a loop that produces those MC
For (j=0 j<10; j + +) {
Removemovieclip (_root["MC" +i+j));//Remove the new MC produced.
}
}
} else {
As.gotoandstop (1);
_root.wen= "Don't flash, let me see it clearly."//Text displayed
}
}
Write here, I do not know if there is anything missing, anyway the core code are above, as for some details on the Dongdong please refer to the source code it!!!

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.