home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / dukeybath.swf / scripts / frame_3 / DoAction.as
Encoding:
Text File  |  2007-03-20  |  6.0 KB  |  272 lines

  1. function resetArrays()
  2. {
  3.    wordFrames = new Array();
  4.    i = 10;
  5.    while(27 >= i)
  6.    {
  7.       wordFrames.push(i);
  8.       i++;
  9.    }
  10.    usedFrames = new Array();
  11.    pickWordFrame();
  12. }
  13. function pickWordFrame()
  14. {
  15.    arrayLength = wordFrames.length;
  16.    if(arrayLength == 0)
  17.    {
  18.       resetArrays();
  19.    }
  20.    else
  21.    {
  22.       var randomNum = Math.floor(Math.random() * arrayLength);
  23.       gotoAndStop(wordFrames[randomNum]);
  24.       usedFrames.push(wordFrames[randomNum]);
  25.       wordFrames.splice(randomNum,1);
  26.    }
  27. }
  28. function newRound()
  29. {
  30.    freebies++;
  31.    guesses = 0;
  32.    badGuesses -= 3;
  33.    if(badGuesses < 0)
  34.    {
  35.       badGuesses = 0;
  36.    }
  37.    letterboxes.gotoAndPlay("showLetters");
  38. }
  39. function wonRound()
  40. {
  41.    alerts.gotoAndPlay("niceJob");
  42.    sound_8.start(0,0);
  43.    flea.gotoAndPlay("sigh");
  44.    deactivateLetterTiles();
  45.    flea.active = true;
  46.    var newTargetY = flea._y - 30;
  47.    if(newTargetY < 100)
  48.    {
  49.       flea.targetY = 100;
  50.    }
  51.    else
  52.    {
  53.       flea.targetY = newTargetY;
  54.    }
  55.    dangerMeter.pin.active = true;
  56.    var newTargetRot = dangerMeter.pin._rotation - 30;
  57.    if(newTargetRot < -65)
  58.    {
  59.       dangerMeter.pin.targetRot = -65;
  60.    }
  61.    else
  62.    {
  63.       dangerMeter.pin.targetRot = newTargetRot;
  64.    }
  65. }
  66. function activateLetterTiles()
  67. {
  68.    var alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
  69.    var i = 0;
  70.    while(i < 26)
  71.    {
  72.       var letter = alphabet[i];
  73.       gameMC.letterboxes[letter].letterbox.gotoAndPlay("active");
  74.       gameMC.letterboxes.free.letterbox.gotoAndPlay("active");
  75.       i++;
  76.    }
  77. }
  78. function deactivateLetterTiles()
  79. {
  80.    var alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
  81.    var i = 0;
  82.    while(i < 26)
  83.    {
  84.       var letter = alphabet[i];
  85.       if(gameMC.letterboxes[letter].letterbox._currentframe < 20)
  86.       {
  87.          gameMC.letterboxes[letter].letterbox.gotoAndPlay("inactive");
  88.       }
  89.       if(gameMC.letterboxes.free.letterbox._currentframe < 20)
  90.       {
  91.          gameMC.letterboxes.free.letterbox.gotoAndPlay("inactive");
  92.       }
  93.       i++;
  94.    }
  95. }
  96. function useFreebie(me)
  97. {
  98.    sound_3.start(0,0);
  99.    freeLetter = lettersUp[0];
  100.    letterboxes[freeLetter].gotoAndPlay("pressed");
  101.    letterboxes[freeLetter].letterbox.gotoAndStop("used");
  102.    lettersUp.splice(0,1);
  103.    arrayLength--;
  104.    j = 1;
  105.    while(wordLength >= j)
  106.    {
  107.       if(freeLetter == word1["letter_" + j].myLetter)
  108.       {
  109.          word1["letter_" + j].gotoAndPlay("showLetter");
  110.          word2["letter_" + j].gotoAndPlay("showLetter");
  111.       }
  112.       j++;
  113.    }
  114.    freebies--;
  115.    if(freebies == 0)
  116.    {
  117.       me.gotoAndStop("used");
  118.       me.num.gotoAndStop("inactive");
  119.    }
  120. }
  121. function testLetter(whichLetter, me)
  122. {
  123.    guesses++;
  124.    var gotOne = false;
  125.    var arrayLength = lettersUp.length - 1;
  126.    i = 0;
  127.    while(arrayLength >= i)
  128.    {
  129.       if(whichLetter == lettersUp[i])
  130.       {
  131.          lettersUp.splice(i,1);
  132.          arrayLength--;
  133.          gotOne = true;
  134.          sound_3.start(0,0);
  135.          j = 1;
  136.          while(wordLength >= j)
  137.          {
  138.             if(whichLetter == word1["letter_" + j].myLetter)
  139.             {
  140.                word1["letter_" + j].gotoAndPlay("showLetter");
  141.                word2["letter_" + j].gotoAndPlay("showLetter");
  142.             }
  143.             j++;
  144.          }
  145.       }
  146.       i++;
  147.    }
  148.    if(gotOne == false)
  149.    {
  150.       sound_6.start(0,0);
  151.       badGuesses++;
  152.       if(badGuesses < 13)
  153.       {
  154.          if(10 < badGuesses)
  155.          {
  156.             alerts.gotoAndPlay("danger");
  157.          }
  158.          scareFlea();
  159.       }
  160.       else
  161.       {
  162.          dropFlea();
  163.       }
  164.    }
  165.    me.gotoAndStop("used");
  166. }
  167. function scareFlea()
  168. {
  169.    dangerMeter.pin.active = true;
  170.    dangerMeter.pin.targetRot += 10;
  171.    flea.active = true;
  172.    flea.targetY += 10;
  173.    flea.gotoAndPlay("flinch");
  174. }
  175. function dropFlea()
  176. {
  177.    showerHead.gotoAndPlay("spray");
  178.    deactivateLetterTiles();
  179.    dangerMeter.pin.active = true;
  180.    dangerMeter.pin.targetRot += 10;
  181.    flea.gotoAndPlay("sway");
  182.    tub.gotoAndPlay("splash");
  183.    sound_1.start(0,0);
  184. }
  185. function resetGame()
  186. {
  187.    gotoAndPlay(3);
  188.    alerts.gotoAndPlay("showInstructions");
  189.    tub.gotoAndPlay(1);
  190.    letterboxes.gotoAndPlay(1);
  191.    showerHead.gotoAndPlay(1);
  192.    flea.gotoAndPlay("idle");
  193.    flea.active = true;
  194.    flea.targetY = 100;
  195.    dangerMeter.pin.active = true;
  196.    dangerMeter.pin.targetRot = -65;
  197. }
  198. function getScore()
  199. {
  200.    return score;
  201. }
  202. function openHelpWin()
  203. {
  204.    trace("displaying help");
  205.    gameMC.helpWin_mc.open();
  206. }
  207. function closeHelpWin()
  208. {
  209.    if(1 < helpWindow._currentframe)
  210.    {
  211.       helpWindow.play();
  212.    }
  213. }
  214. function pause()
  215. {
  216.    helpButton.helpButton.enabled = false;
  217.    set("variables:pause",true);
  218. }
  219. function unPause()
  220. {
  221.    helpButton.helpButton.enabled = true;
  222.    set("variables:pause",false);
  223. }
  224. function getAdInfo()
  225. {
  226.    var ad = {id:1,path:"ad1.jpg",link:"http://www.kidswb.com",text:"howdy"};
  227.    return ad;
  228. }
  229. function adClick()
  230. {
  231.    getURL(gameMC.adInfo.link,"");
  232. }
  233. function displayAd(ad)
  234. {
  235.    gameMC.adInfo = ad;
  236.    gameMC.ad_100x100.loadMovie(ad.path);
  237. }
  238. function restart()
  239. {
  240.    containerMC.resetContainer();
  241.    containerMC.init();
  242.    score = 0;
  243.    which_level = 1;
  244. }
  245. freebies = 3;
  246. guesses = 0;
  247. badGuesses = 0;
  248. gameMC.createEmptyMovieClip("soundLib",1);
  249. i = 1;
  250. while(9 >= i)
  251. {
  252.    soundLib.createEmptyMovieClip("holder_" + i,i);
  253.    gameMC["sound_" + i] = new Sound(soundLib["holder_" + i]);
  254.    i++;
  255. }
  256. sound_1.attachSound("splash");
  257. sound_2.attachSound("curtain");
  258. sound_3.attachSound("pop");
  259. sound_4.attachSound("squeak");
  260. sound_5.attachSound("whoosh");
  261. sound_6.attachSound("slideDown");
  262. sound_7.attachSound("buzzer");
  263. sound_8.attachSound("slideUp");
  264. sound_9.attachSound("johnny");
  265. sound_9.start(0,0);
  266. if(initGame == null)
  267. {
  268.    initGame = true;
  269.    containerMC.init();
  270.    displayAd(containerMC.getAdInfo());
  271. }
  272.