The mouse demo effect is as follows:
http://www.flash8.net/bbs/UploadFile/2005-7/2005715151821114.swf
Click here to download the source file
This is the test program, so only the effect is displayed, and the following is the as script----------------------------------
Stagel = 0;
Staget = 30;
StageR = Stage.width;
Stageb = Stage.height;
The above is the initialization of the selection range;
var my_mc = new Array ();
Create an array to store the MC;
OnLoad ();
Reload_btn.onrelease = function () {
OnLoad ();
};
function onload () {
For (I=1 i<10; i++) {
Test0.duplicatemovieclip ("Test" +i, I);
}
For (i=0 i<10; i++) {
My_mc.push (eval ("Test" +i));
Tests = eval ("test" +i);
Tests._alpha = 100;
tests._x = Random (200) +100;
Tests._y = Random (200) +100;
}
}
Initialize animation elements;
var mouseobj = new Object ();
Mouse.addlistener (Mouseobj);
Monitor mouse events;
Mouseobj.onmousedown = function () {
if (_xmouse>stagel && _xmouse<stager && _ymouse>staget && _ymouse<stageb) {
box_x = _xmouse;
box_y = _ymouse;
Createemptymovieclip ("BOX_MC", 50);
With (BOX_MC) {
LineStyle (1, 0xff0000, 80);
Beginfill (0xff0000, 10);
MoveTo (0, 0);
LineTo (0, 1000);
LineTo (1000, 1000);
LineTo (1000, 0);
LineTo (0, 0);
Endfill ();
_width = 1;
_height = 1;
}
Box_mc.onenterframe = function () {
This._width = Math.Abs (_xmouse-box_x);
This._height = Math.Abs (_ymouse-box_y);
this._x = _xmouse<box_x? _xmouse:box_x;
This._y = _ymouse<box_y? _ymouse:box_y;
};
}
};
The above is to create a marquee within a selection range;
Mouseobj.onmouseup = function () {
This function is to process the data in the scope of the marquee;
if (box_mc!= undefined) {
If the selection box is constructed to perform the control function;
Control ();
Box_mc.removemovieclip ();
}
};
function control () {
For (i=0 i<my_mc.length; i++) {
if (Box_mc.hittest (My_mc[i])) {
The following procedure is the event to be performed for the operation within the marquee or the MC to which the marquee is contacted;
hits = My_mc[i];
Hits._alpha = 40;
In order to visualize the effect, I will be the selection of all the MC transparency changes.
}
}
}