网页代码设计技巧系列之---按钮控制图片移动

上传人:jiups****uk12 文档编号:52271124 上传时间:2018-08-19 格式:DOC 页数:59 大小:32KB
返回 下载 相关 举报
网页代码设计技巧系列之---按钮控制图片移动_第1页
第1页 / 共59页
网页代码设计技巧系列之---按钮控制图片移动_第2页
第2页 / 共59页
网页代码设计技巧系列之---按钮控制图片移动_第3页
第3页 / 共59页
网页代码设计技巧系列之---按钮控制图片移动_第4页
第4页 / 共59页
网页代码设计技巧系列之---按钮控制图片移动_第5页
第5页 / 共59页
点击查看更多>>
资源描述

《网页代码设计技巧系列之---按钮控制图片移动》由会员分享,可在线阅读,更多相关《网页代码设计技巧系列之---按钮控制图片移动(59页珍藏版)》请在金锄头文库上搜索。

1、脚本说明: 把如下代码加入区 域中function Path() this.concat = int_concat; this.add = int_add; this.rotate = int_rot;function int_concat(p) return new PathList(new Array(this, p); function int_add(p) return new PathAdd(this, p); function int_rot(xc,yc,v) return new RotatePath(this, xc, yc, v); / The following objec

2、t is used for the concat function PathList(inPathList) / All path objects must have these 5 methodsthis.x = 0; / Retrieves the current x value this.y = 0; this.step = int_step; / Move to next step this.reset = int_reset; / Resets the current position/ The rest may vary from different path objectsthi

3、s.pathList = inPathList; this.currentPath = 0;function int_step() if (this.currentPath = this.pathList.lengt h) return false; if (this.pathListthis.c urrentPath.step() this.x = this.pathListthis. currentPath.x; this.y = this.pathListthis. currentPath.y; else this.currentPath+; if (this.currentPath =

4、 this.pathList.lengt h) return false; this.x = this.pathListthis. currentPath.x; this.y = this.pathListthis. currentPath.y; return true; function int_reset() this.currentPath = 0; for (var i=0; ifunction CirclePath(x, y, _xr, _yr, fromV, toV, n) / All path objects must have these 5 methods this.x =

5、0; / Retrieves the current x value this.y = 0; this.step = int_step; / Move to next step this.reset = int_reset;/ The rest may vary from different path objectsthis.steps = n; / NN work around. NN cant handle local variables! this.stepsLeft = n; this.xp = x;this.yp = y; this.v = - toRad(fromV); this.

6、startV = this.v; this.endV = - toRad(toV); this.xr = _xr; this.yr = _yr;this.x = getX(this.xp,this.x r,this.v); this.y = getY(this.yp,this.y r,this.v);function toRad(deg) return deg*Math.PI/180; function getX(xp, xr, v) / alert(“xp: “ + xp + “nxr: “ + xr + “nv: “ + v); return xp + xr*Math.cos(v); fu

7、nction getY(yp, yr, v) return yp + yr*Math.sin(v); / Initate steps if (this.steps 0) this.deltaV = (this.endV - this.startV)/n; / work around netscape bug. Netscape couldnt handle this else / as a local variable this.deltaV = 0; this.x = getX(this.xp,this.x r,this.endV); this.y = getY(this.yp,this.y

8、r,this.endV); function int_step() if (this.stepsLeft 0) this.v += this.deltaV; this.x = getX(this.xp,this.xr,this.v); this.y = getY(this.yp,this.y r,this.v);this.stepsLeft-; return true; return false; function int_reset() if (this.steps function StraightPath(fromX, fromY, toX, toY, n) / All path obj

9、ects must have these 5 methods this.x = fromX; / Retrieves the current x value this.y = fromY; this.step = int_step; / Move to next step / Returns true if the step was succesfull / Returns false when the path has been done this.reset = int_reset; / The rest may vary from different path objectsthis.s

10、tartX = fromX; this.startY = fromY; this.endX = toX; this.endY = toY;/ Initiate steps this.steps = n; this.totalSteps = n;if (this.totalSteps = 0) this.steps-; this.x += this.deltaX; this.y += this.deltaY; return (this.steps = 0 ); function int_reset() if (this.totalSteps var animIndex = 0; var anim

11、Array = new Array();function Animator(id, p, period) this.play = int_play; this.pause = int_pause; this.stop = int_stop; this.onanimationdon e; this.elstyle = null; this.path = p;this.msec = period; this.id = id;this.index = animIndex; animArraythis.inde x = this; this.thisString = “animArray“ + thi

12、s.index + “; animIndex+;function int_play() if (this.elstyle = null) / this.elstyle = (document.all != null) ? document.allthis.i d.style : document.layersthis.id; if (document.all) / IE4 this.elstyle = document.allthis.i d.style; else if (document.getElemen tById) / NGLayout this.elstyle = document

13、.getElementById(this.id).style; else if (document.layers) / nn4.x this.elstyle = document.layersthi s.id else return; if (this.path.step() this.elstyle.left = this.path.x; this.elstyle.top = this.path.y; animArraythis.inde x.timer = setTimeout(this.thi sString + “.play()“, this.msec); else if (this.

14、onanimationdo ne != null) if (typeof(this.onanim ationdone) = “string“) eval(this.onanimati ondone); else if (typeof(this.onanim ationdone) = “function“) this.onanimationdon e(); function int_pause() clearTimeout(animArraythis.index.tim er); function int_stop() clearTimeout(animAr raythis.index.tim er); this.path.reset();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号