[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 /* 2 DynAPI Distribution 3 Glide Animation Extension 4 5 The DynAPI Distribution is distributed under the terms of the GNU LGPL license. 6 7 requires: DynLayer, dynapi.functions.Math 8 */ 9 10 function Thread(dlyr) { 11 this.DynObject = DynObject; 12 this.DynObject(); 13 14 if (dlyr) this.dlyr = dlyr; 15 else dlyr = this; // if no dynlayer passed it calls events onto itself 16 17 this._frame = 0; 18 this._path = null; 19 this.loop = false; 20 } 21 var p = dynapi.setPrototype('Thread','DynObject'); 22 p.interval = 20; 23 p.sleep = function (ms) { 24 this.interval = Math.abs(parseInt(ms)); 25 if (this._timer) this.start(); 26 }; 27 p._restart = function () { // starts, or restarts if necessary 28 this.stop(false); 29 setTimeout(this+'.start()',this.interval+1); 30 }; 31 p.start = function () { // starts, or restarts if necessary 32 if (this._timer) this._restart(); 33 else { 34 this.dlyr.invokeEvent("threadstart"); 35 this._timer = setInterval(this+'.run()',this.interval); 36 } 37 }; 38 p.run = function () { 39 var p=this._path, d=this.dlyr; 40 this.dlyr.invokeEvent("threadrun"); 41 if (p && this.dlyr!=this && this._timer) { 42 if (this._frame>=p.length/2) { 43 if (this.loop) this._frame = 0; 44 else { 45 this.stop(false); 46 this.dlyr.invokeEvent("threadfinish"); 47 return; 48 } 49 } 50 if (this._frame==0 && (d.x==p[0] && d.y==p[1])) this.frame += 1; // already at 1st coordinate 51 d.setLocation(p[this._frame*2],p[this._frame*2+1]); 52 this._frame++; 53 } 54 }; 55 p.stop = function (noevt) { 56 clearInterval(this._timer); 57 this._timer = null; 58 this._frame = 0; 59 if (noevt!=false) this.dlyr.invokeEvent("threadstop"); 60 }; 61 p.play = function (path) { 62 this._path = path; 63 this.start(); 64 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |