2015-09-28 25 views
0

我需要创建一个打字测试,我可以将其与我创建的Abode Captivate训练模拟进行集成。我不得不在Flash Professional中创建一个小部件。我已经能够在HTML中创建一个,并试图在Flash Professional中进行复制。这是甚至可能或者我将不得不完全重写我的代码在闪存专业?动作脚本3.0打字测试

这是我的HTML代码,我希望在使用ActionScript 3.0的Flash Professional中使用它。

<!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>

回答

0

事情是这样的:

  1. 创建两个按钮,一个文本区域和一个的TextInput组件,并设置实例名称每个
  2. 拷贝代码到行动框架,并通过添加“VAR”添加型像固定变量:

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

  4. 改变焦点()来的setFocus()

  5. 警报,您可以显示/隐藏一些组件,使它这样反而

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

    可以使用

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