1. Note that a total of three pictures, one is bottom slab (pic_old) placed at the lowest level, a new diagram is switched to (pic_new) placed in the middle layer, and finally a new picture of the Mask layer (mask);
2. The new diagram and bottom slab of the depth should not be reversed, the new picture is higher than the bottom slab depth, otherwise there will be errors;
3. We only make the article on the mask, let the mask to load the mask, so you can accomplish many different effects.
Step 1:
(1) Draw a square (50*50), register point in the center, save for movie clip Connection-> Export-> identifier REC;
(2) Draw a circle (50*50), the registration point in the center, save for the movie clip Connection-> Export-> symbol Cir;
(3) Import Pictures n Zhang, are saved as movie clips, registration point on the left (0,0) These pictures of the connection-> Export-> markers from Pic1, Pic2, pic3 ... picn
Step 2:
Add as code:
var old_p:string;
Temporary variable for storing the current picture
var n:number = 0;
Variable n is the current picture
var num:number = 5;
Num number of pictures
//=======================================================
Click after the mouse to set the bottom layout, new map and mask layer, and call (Passeffect)
_root.onmousedown = function () {
n = n < Num? ++n:1;
_root.createemptymovieclip ("Pic_old",-3);
Pic_old.attachmovie (Old_p, old_p, 1);
old_p = "pic" +N;
_root.createemptymovieclip ("Pic_new",-2);
Pic_new.attachmovie ("pic" +n, pic, 1);
_root.createemptymovieclip ("Mask",-1);
Pic_new[pic].setmask (mask);
When testing, you can comment out the setmask to better observe the mask layer
Passeffect ();
};
//============================================================
function Passeffect () {
Switch (1+math.floor (math.random () *7)) {
effect 1[See Appendix]***************
Copy several circles, distribute each column in each row, and increase the size of each circle to cover the entire picture
Case 1:
For (i=0 i<7; i++) {
For (j=0 j<6; j + +) {
var p:movieclip = Mask.attachmovie ("Cir", "Cir" +i*10+j,
I*10+J);
Note that this is Mask.attachmovie () and that the loaded graphics belong to the Mask layer (mask)
P._width = 20;
P._height = 20;
p._x = 20+i*60;
p._y = 20+j*60;
P.onenterframe = function () {
if (this._width<180) {
This._width = This._height + 8;
} else {
Delete This.onenterframe;
}
};
}
}
Break
//=================================================================
effect 2[See Appendix]***************
Copy a square, put it into the center of the stage, set his initial size to 10*10, and enlarge
Case 2:
var p:movieclip = Mask.attachmovie ("Rec", REC, 1);
P._width = 10;
P._height = 10;
p._x = STAGE.WIDTH/2;
p._y = STAGE.HEIGHT/2;
P.onenterframe = function () {
if (this._width
This._width + 40;
This._height + 40;
} else {
Delete This.onenterframe;
}
};
Break
//=================================================================
effect 3[See Appendix]****************
Copies a square whose initial size is more than the stage's size, making it move to the center of the stage
Case 3:
var p:movieclip = Mask.attachmovie ("rec", "Rec" +1, 1);
P._width = stage.width+10;
P._height = stage.height+10;
p._x = 0-p._width;
p._y = 0-p._height;
P.onenterframe = function () {
This._x + = (stage.width/2-this._x) *0.3;
This._y + = (stage.height/2-this._y) *0.3;
};
Break
//=================================================================
effect 4[See Appendix]***************
Copy two squares and place them on the left and right side of the stage so that they all move toward the center of the stage
Case 4:
var p:movieclip = Mask.attachmovie ("rec", "Rec" +1, 1);
P._width = Stage.width;
P._height = Stage.height;
p._x =-P._WIDTH/2;
p._y = STAGE.HEIGHT/2;
P.onenterframe = function () {
if (this._x
This._x + 15;
} else {
Delete This.onenterframe;
}
};
var p:movieclip = Mask.attachmovie ("rec", "Rec" +2, 2);
P._width = Stage.width;
P._height = Stage.height;
p._x = STAGE.WIDTH+P._WIDTH/2;
p._y = STAGE.HEIGHT/2;
P.onenterframe = function () {
if (THIS._X>STAGE.WIDTH/2) {
this._x-= 15;
} else {
Delete This.onenterframe;
}
};
Break
//=================================================================
effect 5[See Appendix]***************
Randomly produces two tilt angles, using an increment variable d_time to control the start time of each mask object
Case 5:
if (Math.random () <=0.5) {
var rotation = 45;
} else {
var rotation =-45;
}
For (i=-10, d_time=0; i<30; i++, d_time++) {
var p:movieclip = Mask.attachmovie ("rec", "rec" +d_time, d_time);
p._width = 0;
P._height = stage.height*2;
p._x = p._width/2+i*20;
p._y = STAGE.HEIGHT/2;
P._rotation = rotation;
P.delay = D_time;
P.start_time = 0;
P.onenterframe = function () {
if (this.start_time
This.start_time + 3;
else if (this._xscale<30) {
This._xscale + 2;
} else {
Delete This.onenterframe;
}
};
}
Break
//=================================================================
effect 6[See Appendix]***************
Similar to the effect 5, but the size and position of the mask to be slightly changed
Case 6:
if (Math.random () <=0.5) {
For (i=0 i<45; i++) {
var p:movieclip = Mask.attachmovie ("rec", "rec" +i, i);
p._width = 0;
P._height = stage.height+10;
p._x = i*10;
p._y = STAGE.HEIGHT/2;
P.delay = i;
P.start_time = 0;
P.onenterframe = function () {
if (this.start_time
This.start_time + 3;
else if (this._xscale<30) {
This._xscale + 2;
} else {
Delete This.onenterframe;
}
};
}
} else {
For (i=0 i<35; i++) {
var p:movieclip = Mask.attachmovie ("rec", "rec" +i, i);
P._width = stage.width+10;
p._height = 0;
p._x = STAGE.WIDTH/2;
p._y = i*10;
P.delay = i;
P.start_time = 0;
P.onenterframe = function () {
if (this.start_time
This.start_time + 3;
else if (this._yscale<30) {
This._yscale + 2;
} else {
Delete This.onenterframe;
}
};
}
}
Break
//=================================================================
effect 7[See Appendix]***************
case 7
for (i=0; i<40; i++) {
var p:movieclip = mask.attachmovie ("Rec"), "Rec" +i, i);
p._width = 10;
p._height = Stage.height+50;
p._x = p._width/2+i*p._width;
p._y = -p._height+math.random () *50;
p.onenterframe = function () {
if (this._y
this._y += 20;
} else {
delete this.onEnterFrame;
}
};
}
break;
}
}
Flash charging 1 : Movieclip.setmask method Mc.setmask (mask:object): Makes movie clips in parameter mask the mask layer of the MC.
Flash charge 2: conditional operator (three-mesh operation)?: Format: expression1? Expression2:expression3
For example:
var x:number = 5;
var y:number = 10;
var z = (x < 6)? x:y;
Trace (z);
//returns 5