home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / Titans / cyborg.swf / scripts / frame_5 / DoAction.as
Encoding:
Text File  |  2006-01-05  |  3.5 KB  |  165 lines

  1. movieclip.prototype.cekhit = function()
  2. {
  3.    var i = 0;
  4.    while(i < r.bul.length)
  5.    {
  6.       var b = r[r.bul[i]];
  7.       if(b._alpha > 30)
  8.       {
  9.          if(this.hittest(b._x,b._y,1))
  10.          {
  11.             if(math.abs(b.dis - dis) < r.hitrange)
  12.             {
  13.                r.bul.removevalue(r.bul[i]);
  14.                b.removeMovieClip();
  15.                this.hit = 1;
  16.             }
  17.          }
  18.       }
  19.       i++;
  20.    }
  21. };
  22. movieclip.prototype.cekhit2 = function()
  23. {
  24.    var i = 0;
  25.    while(i < r.bul.length)
  26.    {
  27.       var b = r[r.bul[i]];
  28.       if(b._alpha > 30)
  29.       {
  30.          if(math.abs(b.ypoint - this._y) < r.aimrange)
  31.          {
  32.             if(this.z.hittest(b))
  33.             {
  34.                if(math.abs(b.dis - dis) < r.hitrange)
  35.                {
  36.                   r.bul.removevalue(r.bul[i]);
  37.                   b.removeMovieClip();
  38.                   this.hit = 1;
  39.                }
  40.             }
  41.          }
  42.       }
  43.       i++;
  44.    }
  45. };
  46. movieclip.prototype.cekhita = function()
  47. {
  48.    var i = 0;
  49.    while(i < r.bul.length)
  50.    {
  51.       var b = r[r.bul[i]];
  52.       if(math.abs(b.ypoint - this._y) < r.aimrange)
  53.       {
  54.          if(this.a.hittest(b._x,b._y))
  55.          {
  56.             if(math.abs(b.dis - dis) < r.hitrange)
  57.             {
  58.                r.bul.removevalue(r.bul[i]);
  59.                b.removeMovieClip();
  60.                this.hit = 1;
  61.             }
  62.          }
  63.       }
  64.       i++;
  65.    }
  66. };
  67. Movieclip.prototype.findang = function(dx, dy)
  68. {
  69.    return deg(math.atan2(dy,dx));
  70. };
  71. Movieclip.prototype.rad = function(qdeg)
  72. {
  73.    return qdeg * 0.017453292519943295;
  74. };
  75. Movieclip.prototype.deg = function(qrad)
  76. {
  77.    return qrad * 57.29577951308232;
  78. };
  79. Array.prototype.copy = Array.prototype.slice;
  80. Array.prototype.randomize = function()
  81. {
  82.    return this.sort(function(a, b)
  83.    {
  84.       return Math.floor(Math.random() * 2) != 0 ? -1 : 1;
  85.    }
  86.    );
  87. };
  88. Array.prototype.removeElement = function(i)
  89. {
  90.    if(i == null)
  91.    {
  92.       i = 0;
  93.    }
  94.    var r = this[i];
  95.    var j = i;
  96.    while(j < this.length - 1)
  97.    {
  98.       this[j] = this[j + 1];
  99.       j++;
  100.    }
  101.    this.pop();
  102.    return r;
  103. };
  104. Array.prototype.removeValue = function(a)
  105. {
  106.    var i = 0;
  107.    while(i < this.length)
  108.    {
  109.       if(a == this[i])
  110.       {
  111.          this.removeElement(i);
  112.       }
  113.       i++;
  114.    }
  115. };
  116. Color.prototype.setBrightness = function(value)
  117. {
  118.    this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
  119.    var trans = this.getTransform();
  120.    var percent = Math.abs(value) / 100;
  121.    var brightnessColor = value <= 0 ? 0 : 255;
  122.    with(trans)
  123.    {
  124.       ra -= ra * percent;
  125.       ga -= ga * percent;
  126.       ba -= ba * percent;
  127.       rb += (brightnessColor - rb) * percent;
  128.       gb += (brightnessColor - gb) * percent;
  129.       bb += (brightnessColor - bb) * percent;
  130.    }
  131.    this.setTransform(trans);
  132. };
  133. Color.prototype.resetcolor = function()
  134. {
  135.    this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
  136. };
  137. Movieclip.prototype.fadescreen = function(speed)
  138. {
  139.    if(!speed)
  140.    {
  141.       var speed = 5;
  142.    }
  143.    _root.createemptymovieclip("dark",1000001);
  144.    var d = _root.dark;
  145.    with(d)
  146.    {
  147.       lineStyle(1,0,100);
  148.       beginfill(0,100);
  149.       moveto(-5000,-5000);
  150.       lineto(5000,-5000);
  151.       lineto(5000,5000);
  152.       lineto(-5000,5000);
  153.       endfill();
  154.       d.onEnterFrame = function()
  155.       {
  156.          _alpha -= speed;
  157.          if(_alpha <= 0)
  158.          {
  159.             removeMovieClip("");
  160.             stop();
  161.          }
  162.       };
  163.    }
  164. };
  165.