home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / badapple.swf / scripts / DefineSprite_42 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-03-28  |  3.5 KB  |  134 lines

  1. function getNumberSurrounding(checkmyx, checkmyy)
  2. {
  3.    var surTempCount = 0;
  4.    if(1 < checkmyx)
  5.    {
  6.       surTempCount += eval("/apple" + (checkmyx - 1) + checkmyy + ":isbad");
  7.    }
  8.    if(checkmyx < _root.thescript.numx)
  9.    {
  10.       surTempCount += eval("/apple" + (checkmyx + 1) + checkmyy + ":isbad");
  11.    }
  12.    if(1 < checkmyy)
  13.    {
  14.       surTempCount += eval("/apple" + checkmyx + (checkmyy - 1) + ":isbad");
  15.    }
  16.    if(checkmyy < _root.thescript.numy)
  17.    {
  18.       surTempCount += eval("/apple" + checkmyx + (checkmyy + 1) + ":isbad");
  19.    }
  20.    if(1 < checkmyx && 1 < checkmyy)
  21.    {
  22.       surTempCount += eval("/apple" + (checkmyx - 1) + (checkmyy - 1) + ":isbad");
  23.    }
  24.    if(1 < checkmyx && checkmyy < _root.thescript.numy)
  25.    {
  26.       surTempCount += eval("/apple" + (checkmyx - 1) + (checkmyy + 1) + ":isbad");
  27.    }
  28.    if(checkmyx < eval("/thescript:numx") and 1 < checkmyy)
  29.    {
  30.       surTempCount += eval("/apple" + (checkmyx + 1) + (checkmyy - 1) + ":isbad");
  31.    }
  32.    if(checkmyx < eval("/thescript:numx") and checkmyy < eval("/thescript:numy"))
  33.    {
  34.       surTempCount += eval("/apple" + (checkmyx + 1) + (checkmyy + 1) + ":isbad");
  35.    }
  36.    return surTempCount;
  37. }
  38. function clearSurounding(PlaceX, PlaceY)
  39. {
  40.    if(1 < PlaceX)
  41.    {
  42.       CheckSurround(PlaceX - 1,PlaceY);
  43.    }
  44.    if(PlaceX < eval("/thescript:numx"))
  45.    {
  46.       CheckSurround(PlaceX + 1,PlaceY);
  47.    }
  48.    if(1 < PlaceY)
  49.    {
  50.       CheckSurround(PlaceX,PlaceY - 1);
  51.    }
  52.    if(PlaceY < eval("/thescript:numy"))
  53.    {
  54.       CheckSurround(PlaceX,PlaceY + 1);
  55.    }
  56.    if(1 < PlaceX and 1 < PlaceY)
  57.    {
  58.       CheckSurround(PlaceX - 1,PlaceY - 1);
  59.    }
  60.    if(1 < PlaceX and PlaceY < eval("/thescript:numy"))
  61.    {
  62.       CheckSurround(PlaceX - 1,PlaceY + 1);
  63.    }
  64.    if(PlaceX < eval("/thescript:numx") and 1 < PlaceY)
  65.    {
  66.       CheckSurround(PlaceX + 1,PlaceY - 1);
  67.    }
  68.    if(PlaceX < eval("/thescript:numx") and PlaceY < eval("/thescript:numy"))
  69.    {
  70.       CheckSurround(PlaceX + 1,PlaceY + 1);
  71.    }
  72. }
  73. function CheckSurround(CheckPlaceX, CheckPlaceY)
  74. {
  75.    if(checkedArray[CheckPlaceX][CheckPlaceY] == false)
  76.    {
  77.       waiting = _root.theScript.ApplesWaiting[CheckPlaceX][CheckPlaceY];
  78.       if(waiting == true)
  79.       {
  80.          checkedArray[checkPlaceX][CheckPlaceY] = true;
  81.          tempPlace = (CheckPlaceY - 1) * _root.theScript.numX + CheckPlaceX - 1;
  82.          tempCount = getNumberSurrounding(CheckPlaceX,CheckPlaceY);
  83.          _root.theScript.tempcount[tempPlace] = tempcount;
  84.          _root.thescript.numleft -= 1;
  85.          if(eval("/thescript:numleft") == 0)
  86.          {
  87.             set("/thescript:stopclick",true);
  88.          }
  89.          tellTarget("/apple" add CheckPlaceX add CheckPlaceY)
  90.          {
  91.             gotoAndStop("Good");
  92.             play();
  93.          }
  94.          if(tempCount == 0)
  95.          {
  96.             clearSurounding(CheckPlaceX,CheckPlaceY);
  97.          }
  98.       }
  99.    }
  100. }
  101. function clearChecked()
  102. {
  103.    checkedArray = new Array();
  104.    countX = 1;
  105.    countY = 1;
  106.    while(eval("/thescript:numx") >= countx)
  107.    {
  108.       var checkedRow = new Array();
  109.       while(eval("/thescript:numy") >= county)
  110.       {
  111.          checkedrow[county] = false;
  112.          county += 1;
  113.       }
  114.       county = 1;
  115.       checkedArray[countx] = checkedRow;
  116.       countx += 1;
  117.    }
  118. }
  119. function printArray()
  120. {
  121.    countX = 1;
  122.    countY = 1;
  123.    while(eval("/thescript:numx") >= countx)
  124.    {
  125.       while(eval("/thescript:numy") >= county)
  126.       {
  127.          county += 1;
  128.       }
  129.       county = 1;
  130.       countx += 1;
  131.    }
  132. }
  133. appleWaiting = true;
  134.