Mouse
The Flash MX 2004 self-contained window component is not functionally rich. Now, I add the mouse to adjust the size of the window function!!
First look at the animation effect:
http://www.flash8.net/bbs/UploadFile/2005-7/200571514459516.swf
Click here to download the source file
Function:
Small function with mouse scaling
Finger: pointer
Wleast: Min width
Hleast: Minimum degree of height
MovieClip.prototype.MouseSetSize = function (finger:string, Wleast:number, Hleast:number) {
if (wleast = = undefined) {
Wleast = 50;
}
if (hleast = = undefined) {
Hleast = 30;
}
var depth = this.getnexthighestdepth ();//Pointer depth
var mc = this;
var Drag:boolean = false;//Whether it can be scaled
var nm:number;//current pointer sequence number
var px:number;//the mouse x position at the start of the zoom
var py:number;//the mouse y position at the start of the zoom
OnMouseMove = function () {
var xm = mc._xmouse;//relative to mouse x position
var ym = mc._ymouse;//relative to mouse y position
var w = mc.__width;//Component width
var h = mc.__height;//Component High
Scaling components
if (drag) {
if (nm = = 1) {
if (px>=4) {
if (xm<wleast) {
XM = Wleast;
}
Mc.setsize (Math.floor (XM), h);
} else {
Mc.setsize (W-XM, h);
if (w-xm>=wleast) {
mc._x = _xmouse;
} else {
Mc.setsize (Wleast, h);
}
}
else if (nm = = 2) {
if (py>=4) {
if (ymym = Hleast;
}
Mc.setsize (W, Math.floor (YM));
} else {
Mc.setsize (w, H-ym);
if (h-ym>=hleast) {
mc._y = _ymouse;
} else {
Mc.setsize (w, hleast);
}
}
else if (nm = = 3) {
if (py>=4) {
if (ymym = Hleast;
}
Mc.setsize (W-XM, Math.floor (YM));
if (w-xm>=wleast) {
mc._x = _xmouse;
} else {
Mc.setsize (Wleast, Math.floor (YM));
}
} else {
if (xm<wleast) {
XM = Wleast;
}
Mc.setsize (Math.floor (XM), H-ym);
if (h-ym>=hleast) {
mc._y = _ymouse;
} else {
Mc.setsize (w, hleast);
}
}
else if (nm = = 4) {
if (py>=4) {
if (xm<wleast) {
XM = Wleast;
}
if (ymym = Hleast;
}
Mc.setsize (Math.floor (XM), Math.floor (YM));
} else {
Mc.setsize (W-XM, H-ym);
if (w-xm>=wleast) {
mc._x = _xmouse;
} else {
Mc.setsize (Wleast, h);
}
if (h-ym>=hleast) {
mc._y = _ymouse;
} else {
Mc.setsize (w, hleast);
}
}
}
}
To determine whether it is within range
if (xm>=0 && xm<=w && ym>=0 && ym<=h) &&! ( Xm>=3 && xm<=w-3 && ym>=3 && ym<=h-3) {
if (Mc.mouse = = undefined) {
Mouse.hide ();
Mc.attachmovie (finger, "mouse", depth, {_X:XM, _y:ym});
StartDrag (Mc.mouse, true);
NM = 1;
}
if (ym>=15 && ym<=h-15) {
if (nm!= 1) {
Mc.mouse.gotoAndStop (1);
NM = 1;
}
else if (xm>=15 && xm<=w-15) {
if (nm!= 2) {
Mc.mouse.gotoAndStop (2);
NM = 2;
}
else if (ym<=3 && xm>=w-15) | | (ym>=h-3 && xm<=15)) {
if (NM!= 3) {
Mc.mouse.gotoAndStop (3);
NM = 3;
}
else if (ym<=3 && xm<=15) | | (ym>=h-3 && xm>=w-15)) {
if (NM!= 4) {
Mc.mouse.gotoAndStop (4);
NM = 4;
}
}
OnMouseDown = function () {
if (mc.mouse!= undefined) {
drag = true;
px = XM;
py = ym;
}
};
Updateafterevent ();
} else {
if (mc.mouse!= undefined) {
Mc.mouse.removeMovieClip ();
Mouse.show ();
}
}
OnMouseUp = function () {
drag = false;
};
};
};
Use the window. Mousesetsize (Finger, wleast, hleast) can add this function to it!
Furthermore, it can add this function for any rectangular MC, as long as the __width is changed to _width, __height to _height, SetSize method is changed to _width=......,_height= ... It's OK.
Because this method needs to use the onmousemove listener, and to judge a lot of data, it is not appropriate to add this feature for too many windows, otherwise it will be slow to perform!