今天再提供给大家下面几个功能,全部是针对 MovieClip 的,想使用的话加到自己脚本里面去就可以了(浅蓝色框内的脚本可以直接拷贝)。
让浏览器窗口抖动起来。
增强鼠标按钮响应,包括右键和第三键等的响应。
针对某一坐标晃动的 MovieClip,两种方式。
动态设置 MovieClip 的 FPS。
××××××××××
功能:让浏览器窗口抖动起来。
作者:cyberfunk
代码:
Movieclip.prototype.shakewin = function(amount){
getURL("javascript:function shakewin(n){if(parent.moveBy){for(i =
10;i > 0;i--){for(j = n;j > 0;j--
){parent.moveBy(0,i);parent.moveBy(i,0);parent.moveBy(0,
-i);parent.moveBy(-i,0);}}}};shakewin(" + amount + ");void(0)");
} 用法:
onClipEvent(load){
this.shakewin(3);
} ××××××××××
功能:增强鼠标按钮响应,包括右键和第三键等的响应。
作者:sukimashita.com
代码:
getMWDown = function ()
{
return this._onMouseDownEx;
};
setMWDown = function (f)
{
this._MouseHandler = {_parent:this};
this._MouseHandler.onMouseDownEx = function (btn) {
this._parent.onMouseDownEx(btn); };
this._MouseHandler.onMouseUpEx = function (btn) {
this._parent.onMouseUpEx(btn); };
if (f!=undefined) {
Mouse.addListener(this._MouseHandler);
} else {
Mouse.removeListener(this._MouseHandler);
}
this._onMouseDownEx = f;
};
getMWUp = function ()
{
return this._onMouseUpEx;
};
setMWUp = function (f)
{
this._MouseHandler = {_parent:this};
this._MouseHandler.onMouseDownEx = function (btn) {
this._parent.onMouseDownEx(btn); };
this._MouseHandler.onMouseUpEx = function (btn) {
this._parent.onMouseUpEx(btn); };
if (f!=undefined) {
Mouse.addListener(this._MouseHandler);
} else {
Mouse.removeListener(this._MouseHandler);
}
this._onMouseUpEx = f;
};
MovieClip.prototype.addProperty("onMouseDownEx", getMWDown, setMWDown);
MovieClip.prototype.addProperty("onMouseUpEx", getMWUp, setMWUp);
delete getMWUp;
delete setMWUp;
delete getMWDown;
delete setMWDown;
// If DXInput is used 8 buttons max possible...
Mouse.LEFT = 1;
Mouse.RIGHT = 2;
Mouse.MIDDLE = 4;
Mouse.MOUSE1 = 1;
Mouse.MOUSE2 = 2;
Mouse.MOUSE3 = 4;
Mouse.MOUSE4 = 5;
Mouse.MOUSE5 = 6;
Mouse._smbdown = function (f)
{
//trace("_smbdown: ["+f.num+"]: "+f.state);
if (this._mbpressed==undefined)
{
// Init
this._mbpressed = new Array();
};
if ((f.state==true) && (!this._mbpressed[f.num]))
{
this._mbpressed[f.num] = true;
this.broadcastMessage("onMouseDownEx", f.num);
};
if ((f.state==false) && (this._mbpressed[f.num]==true))
{
this._mbpressed[f.num] = false;
this.broadcastMessage("onMouseUpEx", f.num);
};
};
setInterval(function () {
for (var num=1; num < 7; num++)
{
if (Mouse._mbpressed[num]!=ASNative(800,2)(num))
{
Mouse._smbdown({num:num, state:ASNative(800,2)(num)});
};
};
}, 50); 用法:
_root.onMouseDownEx = function (btn)
{
switch (btn)
{
case Mouse.LEFT:
trace("Left mousebutton was pressed!");
break;
case Mouse.RIGHT:
trace("Right mousebutton was pressed!");
break;
case Mouse.MIDDLE:
trace("Middle mousebutton was pressed!");
break;
case Mouse.MOUSE4:
trace("4th mousebutton was pressed!");
break;
case Mouse.MOUSE5:
trace("5th mousebutton was pressed!");
break;
};
};
_root.onMouseUpEx = function (btn)
{
switch (btn)
{
case Mouse.LEFT:
trace("Left mousebutton was released!");
break;
case Mouse.RIGHT:
trace("Right mousebutton was released!");
break;
case Mouse.MIDDLE:
trace("Middle mousebutton was released!");
break;
case Mouse.MOUSE4:
trace("4th mousebutton was released!");
break;
case Mouse.MOUSE5:
trace("5th mousebutton was released!");
break;
};
}; ××××××××××
功能:针对某一坐标晃动的 MovieClip,两种方式。
作者:wu-tang
代码:
//2 functions that provide elastic motion.
//Respects Lithium, for providing code base for this one.
Movieclip.prototype.snapDaddy = function(acc,dec,destY,destX){
this.acc = acc; this.dec = dec; this.destY = destY; this.destX = destX;
this.currX = this._x; this.currY = this._y;
this.diffX = this.destX - this.currX;
this.diffY = this.destY - this.currY;
this.vx = (this.vx + (this.diffX) * 1 / this.acc) / this.dec;
this.vy = (this.vy + (this.diffY) * 1 / this.acc) / this.dec;
this._x += this.vx;
this._y += this.vy;
}
Movieclip.prototype.macDaddy = function(ratio,friction,destY,destX) {
this.ratio = "."+ratio; this.friction = "."+friction;
this.destY = destY; this.destX = destX;
this.speedX = ((this.destX - this._x) * this.ratio) + (this.speedX * this.friction);
this.speedY = ((this.destY - this._y) * this.ratio) + (this.speedY * this.friction);
this._x += this.speedX;
this._y += this.speedY;
}
//enjoy! 用法:
onClipEvent(enterFrame){
this.snapDaddy(.8, 1.7, _root._ymouse, _root._xmouse)
}
onClipEvent(enterFrame){
this.macDaddy(8, 7, _root._ymouse, _root._xmouse);
} ××××××××××
功能:动态设置 MovieClip 的 FPS。
作者:wael
代码:
Movieclip.prototype.setFPS = function(fps)
{
moviePlay = function (clipName)
{
clipName.gotoAndStop(clipName._currentframe + 1);
if (clipName._currentframe == clipName._totalframes)
clearInterval( clipNameID );
}
clipNameID = setInterval(moviePlay, 1000/fps, this);
} 用法:
Jesus.setFPS(5);
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |