home *** CD-ROM | disk | FTP | other *** search
/ Safarir 3 / SafTV-CD3.iso / mac / SAF-TV3 / SAFTV / bush.swf / scripts / frame_15 / DoAction.as
Text File  |  2002-06-17  |  2KB  |  73 lines

  1. function initGame()
  2. {
  3.    quArray = new Array("Son mets favori ","Son argument de choix","Le droit humain le plus fondamental selon lui","Son fantasme le plus obsessionnel","Il leur doit sa gloire","Sa punition favorite");
  4.    repArray = new Array("Un steak saignant","Un missile","Porter une arme","Zigouiller Oussama","Les terroristes Islamistes","La peine de mort");
  5.    q = _root.cv._currentframe;
  6.    y = q - 1;
  7.    x = quArray[y];
  8.    question = x;
  9.    p = repArray[y];
  10.    phrase = p;
  11.    display = "";
  12.    i = 0;
  13.    while(i < phrase.length)
  14.    {
  15.       if(phrase.charAt(i) == " ")
  16.       {
  17.          display += " ";
  18.       }
  19.       else
  20.       {
  21.          display += "_";
  22.       }
  23.       i++;
  24.    }
  25. }
  26. function makeGuess(code)
  27. {
  28.    letter = String.fromCharCode(code);
  29.    if(isAlpha(letter))
  30.    {
  31.       gotOne = false;
  32.       newDisplay = "";
  33.       i = 0;
  34.       while(i < phrase.length)
  35.       {
  36.          if(phrase.charAt(i).toUpperCase() == letter.toUpperCase())
  37.          {
  38.             newDisplay += letter.toUpperCase();
  39.             gotOne = true;
  40.          }
  41.          else
  42.          {
  43.             newDisplay += display.charAt(i);
  44.          }
  45.          i++;
  46.       }
  47.       display = newDisplay;
  48.       if(!gotOne)
  49.       {
  50.          fox.nextFrame();
  51.          if(fox._currentFrame == 6)
  52.          {
  53.             gotoAndPlay(17);
  54.          }
  55.       }
  56.       else if(display == phrase.toUpperCase())
  57.       {
  58.          gotoAndPlay(16);
  59.       }
  60.    }
  61. }
  62. function isAlpha(letter)
  63. {
  64.    n = letter.charCodeAt(0);
  65.    if(90 < n)
  66.    {
  67.       n -= 32;
  68.    }
  69.    return n >= 65 and 90 >= n;
  70. }
  71. initGame();
  72. stop();
  73.