home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / fwg_knight.swf / scripts / __Packages / Exp.as < prev    next >
Encoding:
Text File  |  2008-08-28  |  2.6 KB  |  103 lines

  1. class Exp
  2. {
  3.    var mc;
  4.    var mHit;
  5.    var totalPiece;
  6.    var onEnterFrame;
  7.    var exp;
  8.    var _rotation;
  9.    var va;
  10.    var vx;
  11.    var vy;
  12.    var x;
  13.    var y;
  14.    var vz;
  15.    var g;
  16.    var z;
  17.    var localToGlobal;
  18.    var _parent;
  19.    var _alpha;
  20.    var removeMovieClip;
  21.    var xyObj;
  22.    var _x;
  23.    var _y;
  24.    var onFinish;
  25.    function Exp(_mc, _m2)
  26.    {
  27.       this.mc = _mc;
  28.       this.mHit = _m2;
  29.       this.mc.filters = null;
  30.       this.mc.exp = this;
  31.       this.mc._rotation = 0;
  32.       this.totalPiece = 0;
  33.       this.mc.stop();
  34.       this.mc.onEnterFrame = function()
  35.       {
  36.          delete this.onEnterFrame;
  37.          this.exp.init();
  38.       };
  39.    }
  40.    function init(Void)
  41.    {
  42.       var _loc2_ = undefined;
  43.       var _loc4_ = 1;
  44.       for(var _loc5_ in this.mc)
  45.       {
  46.          _loc2_ = this.mc[_loc5_];
  47.          if(_loc2_._parent == this.mc)
  48.          {
  49.             this.totalPiece = this.totalPiece + 1;
  50.             _loc4_;
  51.             _loc2_.swapDepths(_loc4_++);
  52.             _loc2_.x = 0.1 * _loc2_._y + (Math.random() - 0.5) * 7;
  53.             _loc2_.y = 0.1 * _loc2_._x + (Math.random() - 0.5) * 7;
  54.             _loc2_.z = 0;
  55.             _loc2_.vx = _loc2_.x;
  56.             _loc2_.vy = _loc2_.y;
  57.             _loc2_.vz = 20 * (Math.random() + 0.5);
  58.             _loc2_.va = 10 - Math.random() * 21;
  59.             _loc2_.g = -2;
  60.             _loc2_.onEnterFrame = function()
  61.             {
  62.                this._rotation += this.va;
  63.                this.vx *= 0.95;
  64.                this.vy *= 0.95;
  65.                this.x += this.vx;
  66.                this.y += this.vy;
  67.                this.vz += this.g;
  68.                this.z += this.vz;
  69.                var _loc2_ = {x:_X,y:_Y};
  70.                this.localToGlobal(_loc2_);
  71.                if(this._parent.exp.mHit.hitTest(_loc2_.x,_loc2_.y,true))
  72.                {
  73.                   this.z = 0;
  74.                   this.vz *= -0.2;
  75.                   this._alpha -= 40;
  76.                   if(this._alpha <= 0)
  77.                   {
  78.                      this._parent.exp.delPiece();
  79.                      this.removeMovieClip();
  80.                   }
  81.                }
  82.                this.xyObj = Exp.getXY(this.x,this.y,this.z);
  83.                this._x = this.xyObj._x;
  84.                this._y = this.xyObj._y;
  85.             };
  86.          }
  87.       }
  88.    }
  89.    function delPiece(Void)
  90.    {
  91.       if(--this.totalPiece <= 0)
  92.       {
  93.          this.mc.swapDepths(0);
  94.          this.mc._parent.removeMovieClip();
  95.          this.onFinish();
  96.       }
  97.    }
  98.    static function getXY(x, y, z)
  99.    {
  100.       return {_x:x,_y:- z};
  101.    }
  102. }
  103.