home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / balisa.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2011-06-09  |  4.6 KB  |  211 lines

  1. function getAlphaNum(number)
  2. {
  3.    toReturn = "";
  4.    while(number > 0)
  5.    {
  6.       unite = number % baseAlphaNum;
  7.       if(unite < 10)
  8.       {
  9.          toReturn = String.fromCharCode(unite + 48) + toReturn;
  10.       }
  11.       else if(unite < 36)
  12.       {
  13.          toReturn = String.fromCharCode(unite + 55) + toReturn;
  14.       }
  15.       else
  16.       {
  17.          toReturn = String.fromCharCode(unite + 61) + toReturn;
  18.       }
  19.       number = (number - unite) / baseAlphaNum;
  20.    }
  21.    return toReturn;
  22. }
  23. function getNumber(alphanum)
  24. {
  25.    toReturn = 0;
  26.    l = alphanum.length;
  27.    i = 0;
  28.    while(i < l)
  29.    {
  30.       unite = alphanum.charCodeAt(i);
  31.       if(unite >= 48 && unite < 58)
  32.       {
  33.          toReturn = toReturn * baseAlphaNum + unite - 48;
  34.       }
  35.       else if(unite >= 65 && unite < 91)
  36.       {
  37.          toReturn = toReturn * baseAlphaNum + unite - 55;
  38.       }
  39.       else if(unite >= 97 && unite < 123)
  40.       {
  41.          toReturn = toReturn * baseAlphaNum + unite - 61;
  42.       }
  43.       i++;
  44.    }
  45.    return toReturn;
  46. }
  47. function playSurround(show)
  48. {
  49.    if(show)
  50.    {
  51.       playback._visible = play_btn._visible;
  52.       playback.gotoAndPlay(1);
  53.    }
  54.    else
  55.    {
  56.       playback._visible = false;
  57.    }
  58. }
  59. function showButtons(vis)
  60. {
  61.    pause_btn._visible = vis;
  62.    play_btn._visible = vis;
  63.    stop_btn._visible = vis;
  64.    playback._visible = vis;
  65. }
  66. function clicStart()
  67. {
  68.    if(!_root.timing)
  69.    {
  70.       menuder._visible = false;
  71.       if(_root.voitureverte.gare && _root.voitureverte.replayPlay == false)
  72.       {
  73.          _root.timer_txt = "00:00:00:00";
  74.          _root.voitureverte.init();
  75.          _root.voitureverte.initReplayRec();
  76.       }
  77.       if(!_root.paused)
  78.       {
  79.          startFrame = frame;
  80.       }
  81.       _root.paused = false;
  82.       _root.timing = true;
  83.       aidetimestart = -1;
  84.    }
  85. }
  86. function clicStop()
  87. {
  88.    _root.timing = false;
  89.    _root.paused = false;
  90.    _root.timer_txt = "00:00:00:00";
  91.    chocs_txt = "";
  92.    art_txt = "";
  93.    playSurround(true);
  94.    menuder._visible = true;
  95.    _root.voitureverte.init();
  96.    _root.voitureverte.initReplayRec();
  97.    aidetimestart = getTimer();
  98. }
  99. var vX = _root.voitureverte._x;
  100. var vY = _root.voitureverte._y;
  101. var vRot = _root.voitureverte._rotation;
  102. var xCorps = _root.voitureverte.bustebras._x;
  103. var yCorps = _root.voitureverte.bustebras._y;
  104. var xTete = _root.voitureverte.tete._x;
  105. var yTete = _root.voitureverte.tete._y;
  106. var frame = 0;
  107. var startFrame = 0;
  108. var baseAlphaNum = 62;
  109. var timing = false;
  110. chocs_txt = "";
  111. art_txt = "";
  112. aidetimestart = getTimer();
  113. _root.play_btn.onPress = function()
  114. {
  115.    clicStart();
  116. };
  117. _root.stop_btn.onPress = function()
  118. {
  119.    clicStop();
  120. };
  121. _root.pause_btn.onPress = function()
  122. {
  123.    if(_root.timing)
  124.    {
  125.       _root.timing = false;
  126.       _root.paused = true;
  127.       playSurround(true);
  128.    }
  129. };
  130. _root.onEnterFrame = function()
  131. {
  132.    if(voitureverte.chocs > 0)
  133.    {
  134.       chocs_txttmp = "chocs : " + voitureverte.chocs;
  135.    }
  136.    else
  137.    {
  138.       chocs_txttmp = "";
  139.    }
  140.    if(voitureverte.noteArtistique > 0)
  141.    {
  142.       art_txttmp = "artistique : " + voitureverte.noteArtistique;
  143.    }
  144.    else
  145.    {
  146.       art_txttmp = "";
  147.    }
  148.    if(art_txttmp != art_txt)
  149.    {
  150.       art_txt = art_txttmp;
  151.    }
  152.    if(chocs_txttmp != chocs_txt)
  153.    {
  154.       chocs_txt = chocs_txttmp;
  155.    }
  156.    if(aidetimestart != -1 && getTimer() - aidetimestart > 2000)
  157.    {
  158.       _root.aide._visible = true;
  159.    }
  160.    else
  161.    {
  162.       _root.aide._visible = false;
  163.    }
  164.    if(timing)
  165.    {
  166.       playSurround(false);
  167.       elapsedTime = (frame - startFrame) * 100 / 3;
  168.       elapsedHours = Math.floor(elapsedTime / 3600000);
  169.       remaining = elapsedTime - elapsedHours * 3600000;
  170.       elapsedM = Math.floor(remaining / 60000);
  171.       remaining -= elapsedM * 60000;
  172.       elapsedS = Math.floor(remaining / 1000);
  173.       remaining -= elapsedS * 1000;
  174.       elapsedH = Math.floor(remaining / 10);
  175.       if(elapsedHours < 10)
  176.       {
  177.          hours = "0" + elapsedHours.toString();
  178.       }
  179.       else
  180.       {
  181.          hours = elapsedHours.toString();
  182.       }
  183.       if(elapsedM < 10)
  184.       {
  185.          minutes = "0" + elapsedM.toString();
  186.       }
  187.       else
  188.       {
  189.          minutes = elapsedM.toString();
  190.       }
  191.       if(elapsedS < 10)
  192.       {
  193.          seconds = "0" + elapsedS.toString();
  194.       }
  195.       else
  196.       {
  197.          seconds = elapsedS.toString();
  198.       }
  199.       if(elapsedH < 10)
  200.       {
  201.          hundredths = "0" + elapsedH.toString();
  202.       }
  203.       else
  204.       {
  205.          hundredths = elapsedH.toString();
  206.       }
  207.       _root.timer_txt = hours + ":" + minutes + ":" + seconds + ":" + hundredths;
  208.       frame++;
  209.    }
  210. };
  211.