lundi 28 septembre 2015

Action script 3.0 Typing Test

I am needing to create a typing test that I can integrate in with an Abode Captivate training simulation I have created. I am having to create a widget in flash professional. I have been able to create one in HTML and was just going to try and replicate it in Flash Professional. Is that even possible or would I have to completely re-write my code in flash professional?

Here is my HTML code and I am wanting it in Flash Professional using ActionScript 3.0.

<!DOCTYPE html>
<html>

<HEAD>

  <script language="JavaScript">
    msg = new Array("After awhile, finding that nothing more happened, she decided on going into the garden at once; but, alas for poor Alice! When she got to the door, she found she had forgotten the little golden key, and when she went back to the table for it, she found she could not possibly reach it: she could see it quite plainly through the glass and she tried her best to climb up one of the legs of the table, but it was too slippery, and when she had tired herself out with trying, the poor little thing sat down and cried.")
     word = 10

    function m() {
      msg = new Array("After awhile, finding that nothing more happened, she decided on going into the garden at once; but, alas for poor Alice! When she got to the door, she found she had forgotten the little golden key, and when she went back to the table for it, she found she could not possibly reach it: she could see it quite plainly through the glass and she tried her best to climb up one of the legs of the table, but it was too slippery, and when she had tired herself out with trying, the poor little thing sat down and cried.")
      word = 10
    }


    function beginIt() {
      randNum = Math.floor((Math.random() * 10)) % 4
      msgType = msg
      day = new Date();
      startType = day.getTime();
      document.theForm.given.value = msgType
      document.theForm.typed.focus();
      document.theForm.typed.select();
    }

    function cheat() {
      alert("You can not change that!");
      document.theForm.typed.focus();
    }

    function stopIt() {
      dayTwo = new Date();
      endType = dayTwo.getTime();
      totalTime = ((endType - startType) / 1000)
      spd = Math.round((word / totalTime) * 60)

      if (document.theForm.typed.value == document.theForm.given.value) {
        alert("\nYou typed a " + word + " word sentence in " + totalTime + " seconds, a speed of about " + spd + " words per minute!")
      } else {
        alert("You made an error, but typed at a speed of " + spd + " words per minute.")
      }
    }
  </script>

</head>

<body>
  <center>
    <form name="theForm">
      <table border=3 cellspacing=0 cellpadding=0>
        <tr>
          <td colspan=2>
            <br>
            <center>
              <input type=button value="Start Typing Test" name="start" onClick="beginIt()">
            </center>
            <P>
              <textarea name="given" cols=53 rows=10 wrap=on onFocus="cheat()"></textarea>
          </TD>
        </tr>
        <tr>
          <td colspan=2>
            <center>
              <input type=text name="typed" size=45>
              <input type=button value="DONE" name="stop" onClick="stopIt()">
            </center>
          </TD>
        </tr>
      </table>
    </form>
  </center>
</body>

</html>

Aucun commentaire:

Enregistrer un commentaire