2015-09-28 36 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!");