资源预览内容
第1页 / 共59页
第2页 / 共59页
第3页 / 共59页
第4页 / 共59页
第5页 / 共59页
第6页 / 共59页
第7页 / 共59页
第8页 / 共59页
第9页 / 共59页
第10页 / 共59页
亲,该文档总共59页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
脚本说明: 把如下代码加入区 域中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 object 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 objectsthis.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 = 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 = 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.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); function 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.yr,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 objects 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.startX = 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 animArray = new Array();function Animator(id, p, period) this.play = int_play; this.pause = int_pause; this.stop = int_stop; this.onanimationdon e; this.elthis.path = p;this.msec = period; this.id = id;this.index = animIndex; animArraythis.inde x = this; this.thisString = “animArray“ + this.index + “; animIndex+;function int_play() if (this.el/ this.el!= null) ? document.allthis.i d.style : document.layersthis.id; if (document.all) / IE4 this.eld.style; else if (document.getElemen tById) / NGLayout this.elelse if (document.layers) / nn4.x this.els.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.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();
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号