home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / cool_balls.swf / scripts / frame_2 / DoAction.as
Encoding:
Text File  |  2006-06-13  |  7.5 KB  |  251 lines

  1. function setvol(vol)
  2. {
  3.    _root.sound.setVolume(vol);
  4. }
  5. function happyend()
  6. {
  7.    _root.reinit();
  8.    _global.tmp = 4;
  9.    _root.onEnterFrame = function()
  10.    {
  11.       _global.tmp = _global.tmp - 1;
  12.       if(_global.tmp == 0)
  13.       {
  14.          _global.tmp = 120;
  15.          _root.onEnterFrame = function()
  16.          {
  17.             _global.tmp = _global.tmp - 1;
  18.             if(_global.tmp == 0)
  19.             {
  20.                _root.onEnterFrame = null;
  21.                if(_global.lev < 12)
  22.                {
  23.                   var _loc3_ = 1;
  24.                   while(_loc3_ < 13)
  25.                   {
  26.                      var _loc4_ = new Color(_root.colorer[_loc3_]);
  27.                      _loc4_.setRGB(0);
  28.                      _loc3_ = _loc3_ + 1;
  29.                   }
  30.                   var _loc5_ = new Color("_root.b" + (_global.lev + 1));
  31.                   _loc5_.setRGB(11141120);
  32.                   _root.exe.starter(_global.lev + 1);
  33.                }
  34.                else
  35.                {
  36.                   _root.exe.starter(12);
  37.                }
  38.             }
  39.          };
  40.          _root.congratulations._visible = true;
  41.          _root.congratulations.gotoAndPlay(2);
  42.       }
  43.    };
  44. }
  45. function reinit()
  46. {
  47.    _root.congratulations._visible = false;
  48.    _global.spherecounter = 0;
  49.    var _loc4_ = 1;
  50.    while(_loc4_ <= 9)
  51.    {
  52.       var _loc3_ = 1;
  53.       while(_loc3_ <= 9)
  54.       {
  55.          _root.quadros[_loc4_ + 10 * _loc3_].gotoAndPlay("die");
  56.          _root.links[_loc4_ + 10 * _loc3_] = null;
  57.          _root.bools[_loc4_ + 10 * _loc3_] = 0;
  58.          _root.spheres[_loc4_ + 10 * _loc3_].gotoAndPlay("die");
  59.          _loc3_ = _loc3_ + 1;
  60.       }
  61.       _loc4_ = _loc4_ + 1;
  62.    }
  63.    _root.quadros = new Array();
  64.    _root.spheres = new Array();
  65. }
  66. function initerOnPress()
  67. {
  68.    this.startDrag(false);
  69.    this.onMouseUp = _root.initerOnMouseUp;
  70. }
  71. function initerOnMouseUp()
  72. {
  73.    this.stopDrag();
  74.    var _loc5_ = 1;
  75.    while(_loc5_ <= i)
  76.    {
  77.       var _loc4_ = 1;
  78.       while(_loc4_ <= j)
  79.       {
  80.          if(_root.bools[_loc5_ + 10 * _loc4_] == 0 && this._x + 12.5 >= 28 * (_loc5_ - 1) && this._x + 12.5 <= 28 * _loc5_ && this._y + 12.5 >= 28 * (_loc4_ - 1) && this._y + 12.5 <= 28 * _loc4_ && (this.c1 == _loc5_ && Math.abs(this.c2 - _loc4_) == 2 || this.c2 == _loc4_ && Math.abs(this.c1 - _loc5_) == 2))
  81.          {
  82.             if(this.c1 == _loc5_ && _root.bools[_loc5_ + 5 * (_loc4_ + this.c2)] == 1 || this.c2 == _loc4_ && _root.bools[(_loc5_ + this.c1) / 2 + 10 * _loc4_] == 1)
  83.             {
  84.                _root.bools[this.c1 + 10 * this.c2] = 0;
  85.                _root.links[this.c1 + 10 * this.c2] = null;
  86.                _root.bools[_loc5_ + 10 * _loc4_] = 1;
  87.                _root.bools[(_loc5_ + this.c1) / 2 + 5 * (_loc4_ + this.c2)] = 0;
  88.                _root.s[0].start();
  89.                _root.links[(_loc5_ + this.c1) / 2 + 5 * (_loc4_ + this.c2)].gotoAndPlay("die");
  90.                _global.spherecounter = _global.spherecounter - 1;
  91.                _global.spherescore = _global.spherescore + 1;
  92.                _root.links[_loc5_ + 10 * _loc4_] = this;
  93.                this._x = 29 * (_loc5_ - 1);
  94.                this._y = 29 * (_loc4_ - 1);
  95.                this.ok = true;
  96.                this.c1 = _loc5_;
  97.                this.c2 = _loc4_;
  98.                if(_global.spherecounter == 1)
  99.                {
  100.                   _root.s[2].start();
  101.                   _root.happyend();
  102.                }
  103.             }
  104.          }
  105.          _loc4_ = _loc4_ + 1;
  106.       }
  107.       _loc5_ = _loc5_ + 1;
  108.    }
  109.    if(!this.ok)
  110.    {
  111.       _root.s[3].start();
  112.       this._x = 29 * (this.c1 - 1);
  113.       this._y = 29 * (this.c2 - 1);
  114.    }
  115.    _root.scores.scores_box.text = _global.spherescore;
  116.    this.ok = false;
  117.    this.onMouseUp = null;
  118. }
  119. function h1(smth)
  120. {
  121.    _root.s[5].start();
  122.    var _loc5_ = this._name;
  123.    _loc5_ = _loc5_.substr(1);
  124.    var _loc3_ = 1;
  125.    while(_loc3_ < 13)
  126.    {
  127.       var _loc4_ = new Color(_root.colorer[_loc3_]);
  128.       _loc4_.setRGB(0);
  129.       _loc3_ = _loc3_ + 1;
  130.    }
  131.    var _loc6_ = new Color(this);
  132.    _loc6_.setRGB(11141120);
  133.    _root.exe.starter(Number(_loc5_));
  134. }
  135. stop();
  136. _root.soundoff._visible = false;
  137. var sound = new Sound();
  138. var s = new Array(new Sound(),new Sound(),new Sound(),new Sound(),new Sound(),new Sound());
  139. var t1 = 0;
  140. while(t1 < 6)
  141. {
  142.    s[t1].attachSound("s" + (t1 + 1));
  143.    s[t1].setVolume(50);
  144.    t1++;
  145. }
  146. _root.volsontrol.roller._y = 35;
  147. var colorer = new Array();
  148. colorer[1] = _root.b1;
  149. colorer[2] = _root.b2;
  150. colorer[3] = _root.b3;
  151. colorer[4] = _root.b4;
  152. colorer[5] = _root.b5;
  153. colorer[6] = _root.b6;
  154. colorer[7] = _root.b7;
  155. colorer[8] = _root.b8;
  156. colorer[9] = _root.b9;
  157. colorer[10] = _root.b10;
  158. colorer[11] = _root.b11;
  159. colorer[12] = _root.b12;
  160. _root.congratulations._visible = false;
  161. var tmpbool;
  162. var drag = false;
  163. _global.spherecounter;
  164. _global.spherescore = 0;
  165. _global.tmp = 3;
  166. _global.lev = 1;
  167. _global.i = 0;
  168. _global.j = 0;
  169. var mydef = new arrdefine();
  170. var exe = new Object();
  171. var initer = new Object();
  172. var quadros = new Array();
  173. var spheres = new Array();
  174. var bools = new Array();
  175. var links = new Array();
  176. initer.onMouseUp = initerOnMouseUp;
  177. initer.onPress = initerOnPress;
  178. exe.setPfieldSize = function()
  179. {
  180.    _root.pfield._x = (330 - 29 * j) / 2;
  181.    _root.pfield._y = (300 - 29 * (i - 1)) / 2;
  182.    var _loc4_ = 1;
  183.    while(_loc4_ <= _global.i)
  184.    {
  185.       var _loc3_ = 1;
  186.       while(_loc3_ <= _global.j)
  187.       {
  188.          _root.initer._x = 29 * (_loc4_ - 1);
  189.          _root.initer._y = 29 * (_loc3_ - 1);
  190.          _root.quadros[_loc4_ + 10 * _loc3_] = _root.pfield.attachMovie("quadro","quadro" + _loc4_ + _loc3_,_loc4_ - 1000 * _loc3_,_root.initer);
  191.          _root.quadros[_loc4_ + 10 * _loc3_].onPress = null;
  192.          _root.quadros[_loc4_ + 10 * _loc3_].onMouseUp = null;
  193.          if(_root.mydef.net[_global.lev - 1][_loc4_ + _global.i * (_loc3_ - 1) - 1])
  194.          {
  195.             _root.bools[_loc4_ + 10 * _loc3_] = 1;
  196.             _root.spheres[_loc4_ + 10 * _loc3_] = new Object();
  197.             _global.spherecounter = _global.spherecounter + 1;
  198.             _root.spheres[_loc4_ + 10 * _loc3_] = _root.pfield.attachMovie("sphere","sphere" + _loc4_ + _loc3_,20 + _loc4_ + _loc3_ * 10,_root.initer);
  199.             _root.links[_loc4_ + 10 * _loc3_] = _root.spheres[_loc4_ + 10 * _loc3_];
  200.             _root.spheres[_loc4_ + 10 * _loc3_].onMouseUp = null;
  201.             _root.spheres[_loc4_ + 10 * _loc3_].c1 = _loc4_;
  202.             _root.spheres[_loc4_ + 10 * _loc3_].c2 = _loc3_;
  203.             _root.spheres[_loc4_ + 10 * _loc3_].ok = false;
  204.          }
  205.          _loc3_ = _loc3_ + 1;
  206.       }
  207.       _loc4_ = _loc4_ + 1;
  208.    }
  209.    _root.scores.scores_box.text = _global.spherescore;
  210. };
  211. exe.starter = function(lev)
  212. {
  213.    _global.spherescore = 0;
  214.    _root.scores.scores_box.text = _global.spherescore;
  215.    _root.reinit();
  216.    _global.lev = lev;
  217.    _global.tmp = 4;
  218.    _root.onEnterFrame = function()
  219.    {
  220.       if(_global.tmp > 0)
  221.       {
  222.          _global.tmp = _global.tmp - 1;
  223.       }
  224.       else
  225.       {
  226.          _root.onEnterFrame = null;
  227.          _root.mydef.setlevel(lev);
  228.          _root.exe.setPfieldSize();
  229.       }
  230.    };
  231. };
  232. with(_root)
  233. {
  234.    b1.onRelease = h1;
  235.    b2.onRelease = h1;
  236.    b3.onRelease = h1;
  237.    b4.onRelease = h1;
  238.    b5.onRelease = h1;
  239.    b6.onRelease = h1;
  240.    b7.onRelease = h1;
  241.    b8.onRelease = h1;
  242.    b9.onRelease = h1;
  243.    b10.onRelease = h1;
  244.    b11.onRelease = h1;
  245.    b12.onRelease = h1;
  246.    b13.onRelease = h1;
  247. }
  248. var mycolor = new Color(_root.b1);
  249. mycolor.setRGB(11141120);
  250. _root.exe.starter(1);
  251.