动作脚本3.0键入测试

时间:2015-09-28 19:41:45

标签: javascript actionscript-3 flex flash-builder flashdevelop

我需要创建一个打字测试,我可以将其与我创建的Abode Captivate培训模拟集成。我不得不在flash专业版中创建一个小部件。我已经能够用HTML创建一个,并且只是尝试在Flash Professional中复制它。这是可能的还是我必须在flash专业人员中完全重写我的代码?

这是我的HTML代码,我想在Flash Professional中使用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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

这样的事情:

  1. 创建两个按钮,一个 TextArea 和一个 TextInput 组件,并将实例名称设置为每个
  2. 通过添加“var”添加类型将代码复制到操作框架并修复变量,如:

    var msg:Array = new Array("After awhile, ... and cried.")
    var word:int = 10
    
  3. 删除所有“document.theForm。”

  4. 将focus()更改为setFocus()

  5. 对于提醒,您可以显示/隐藏某些组件,而不是

    alert("You can not change that!");
    

    你可以使用

     myAlert.show("You can not change that!");