Flash MX 2004自带的Window组件,功用并不丰富。如今,我为它加上了用鼠标调整窗口的大小的功用!!
先看看动画效果:
点击这里下载源文件
函数:
//随鼠标缩放大小函数
//finger:指针
//wLeast:最小宽度
//hLeast:最小高度度
MovieClip.prototype.MouseSetSize = function(finger:String, wLeast:Number, hLeast:Number) {
if (wLeast == undefined) {
wLeast = 50;
}
if (hLeast == undefined) {
hLeast = 30;
}
var depth = this.getNextHighestDepth();//指针深度
var mc = this;
var drag:Boolean = false;//能否可以缩放
var nm:Number;//当前指针序号
var px:Number;//缩放开始时的鼠标x位置
var py:Number;//缩放开始时的鼠标y位置
onMouseMove = function() {
var xm = mc._xmouse;//绝对鼠标x位置
var ym = mc._ymouse;//绝对鼠标y位置
var w = mc.__width;//组件宽
var h = mc.__height;//组件高
//缩放组件
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 (ym<hLeast) {
ym = 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 (ym<hLeast) {
ym = 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 (ym<hLeast) {
ym = 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);
}
}
}
}
//判断能否在范围内
if ((xm>=0 && xm<=w && ym>=0 && ym<=h) && !(xm>=3 && xm<=w-3 && ym>=3 && ym<=h-3)) {
if (mc.mouse == und