[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/js/dynapi/fx/ -> pathanim.js (source)

   1  /*
   2      DS: the extra features of this version will possibly be rebuilt as an advanced timeline object
   3      
   4      DynAPI Distribution
   5      PathAnimation Class
   6  
   7      The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
   8  
   9      requires: dynapi.fx.Thread
  10  */
  11  
  12  function PathAnimation(dlyr) {
  13      this.Thread = Thread;
  14      this.Thread(dlyr);
  15      this.paths = [];
  16      this.pathPlaying = null;
  17  }
  18  var p = dynapi.setPrototype('PathAnimation','Thread');
  19  
  20  p.add = function (path, loops, resets) {
  21      var n = this.paths.length;
  22      this.paths[n] = path;
  23      this.setLoops(n,loops);
  24      this.setResets(n,resets);
  25      this.setFrame(n,0);
  26      return n;
  27  };
  28  p.setLoops = function (n, loops) {
  29      this.paths[n].loops = (loops);
  30  };
  31  p.setResets = function (n, resets) {
  32      this.paths[n].resets = (resets);
  33  };
  34  p.setFrame = function (n, frame) {
  35      this.paths[n].frame = frame;
  36  };
  37  p.playAnimation = function (noevt) {
  38      if (!this.playing) {
  39          this.pathPlaying = null;
  40          if (arguments[0]==null) arguments[0] = 0;
  41          if (typeof(arguments[0]) == "number") {
  42              this.pathPlaying = this.paths[arguments[0]];
  43          }
  44          else if (typeof(arguments[0]) == "object") {  
  45              this.pathPlaying = arguments[0];
  46              this.pathPlaying.loops = arguments[1]||false;
  47              this.pathPlaying.resets = arguments[2]||false;
  48              this.pathPlaying.frame = 0;
  49          }
  50          this.playing = true;
  51          if (this.dlyr!=null && noevt!=false) this.dlyr.invokeEvent("pathstart");
  52          this.start();
  53      }
  54  };
  55  //p._Thread_stop = Thread.prototype.stop;
  56  p.stopAnimation = function (noevt) {
  57      if (this.pathPlaying && this.pathPlaying.resets && this.dlyr!=null) this.dlyr.setLocation(this.pathPlaying[0],this.pathPlaying[1]);
  58      this.stop();
  59      this.pathPlaying = null;
  60      this.playing = false;
  61      if (this.dlyr!=null && noevt!=false) this.dlyr.invokeEvent("pathstop");
  62  };
  63  p.run = function () {
  64      if (!this.playing || this.pathPlaying==null) return;
  65      var anim = this.pathPlaying;
  66      if (anim.frame>=anim.length/2) {
  67          if (anim.loops) {
  68              anim.frame = 0;
  69          }
  70          else if (anim.resets) {
  71              anim.frame = 0;
  72              if (this.dlyr!=null) this.dlyr.setLocation(anim[0],anim[1]);
  73              this.stopAnimation();
  74              this.dlyr.invokeEvent("pathfinish");
  75              return;
  76          }
  77          else {
  78              anim.frame = 0;
  79              this.stopAnimation();
  80              this.dlyr.invokeEvent("pathfinish");
  81              return;
  82          }
  83      }
  84      if (anim.frame==0 && (this.dlyr!=null && this.dlyr.x==anim[0] && this.dlyr.y==anim[1])) {
  85          anim.frame += 1;
  86      }
  87      this.newX = anim[anim.frame*2];
  88      this.newY = anim[anim.frame*2+1];
  89      
  90      if (this.dlyr!=null) {
  91          this.dlyr.invokeEvent("pathrun");
  92          this.dlyr.setLocation(this.newX,this.newY);
  93      }
  94      anim.frame++;
  95  };
  96  


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7