home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / starisland.swf / scripts / __Packages / huang / HAnimation.as < prev    next >
Encoding:
Text File  |  2007-12-10  |  1.9 KB  |  73 lines

  1. class huang.HAnimation
  2. {
  3.    var dmc;
  4.    var Hpath;
  5.    var vloop = 0;
  6.    var times = 0;
  7.    var pnow = 0;
  8.    function HAnimation(mc, path)
  9.    {
  10.       this.dmc = eval(mc);
  11.       this.Hpath = path;
  12.    }
  13.    function Start()
  14.    {
  15.       var myClass = this;
  16.       this.dmc.onEnterFrame = function()
  17.       {
  18.          if(myClass.DoSomeAnimation())
  19.          {
  20.             myClass.Hpath[myClass.pnow].bloop <= 0 ? myClass.pnow++ : myClass.Hpath[myClass.pnow].bloop--;
  21.             if(myClass.Hpath.length - myClass.pnow < 2)
  22.             {
  23.                if(myClass.vloop < 1)
  24.                {
  25.                   delete myClass.dmc.onEnterFrame;
  26.                   myClass.Arrived();
  27.                }
  28.                else
  29.                {
  30.                   myClass.vloop--;
  31.                   myClass.pnow = 0;
  32.                }
  33.             }
  34.          }
  35.       };
  36.    }
  37.    function Arrived()
  38.    {
  39.       this.dmc.gotoAndPlay(this.Hpath[this.pnow].framename);
  40.    }
  41.    function Close()
  42.    {
  43.       delete this.dmc.onEnterFrame;
  44.       false;
  45.    }
  46.    function DoSomeAnimation()
  47.    {
  48.       if(this.times == 0)
  49.       {
  50.          this.dmc._x = this.Hpath[this.pnow].x;
  51.          this.dmc._y = this.Hpath[this.pnow].y;
  52.       }
  53.       if(this.times < this.Hpath[this.pnow].step)
  54.       {
  55.          this.DoMovement();
  56.          this.times = this.times + 1;
  57.          return false;
  58.       }
  59.       this.times = 0;
  60.       return true;
  61.    }
  62.    function DoMovement()
  63.    {
  64.       this.dmc._x += (this.Hpath[this.pnow + 1].x - this.Hpath[this.pnow].x) / this.Hpath[this.pnow].step;
  65.       this.dmc._y += (this.Hpath[this.pnow + 1].y - this.Hpath[this.pnow].y) / this.Hpath[this.pnow].step;
  66.       this.dmc._rotation += this.Hpath[this.pnow].gama;
  67.       if(this.Hpath[this.pnow].framename != undefined)
  68.       {
  69.          this.dmc.gotoAndStop(this.Hpath[this.pnow].framename);
  70.       }
  71.    }
  72. }
  73.