AutoType.as:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Other{ | |
import fl.controls.TextArea; | |
import flash.utils.Timer; | |
import flash.events.TimerEvent; | |
public class AutoType{ | |
private var typeSpeed=5; | |
private var msgArray:Array; | |
private var tArea:TextArea; | |
private var sTimer:Timer; | |
private var i=0; | |
public function AutoType(){ | |
trace("AutoTyper has been loaded."); | |
} | |
public function sendMsg(Msg:String,textArea:TextArea):void{ | |
tArea=textArea; | |
msgArray=Msg.split(""); | |
sTimer=new Timer(typeSpeed*10, 1); | |
sTimer.addEventListener(TimerEvent.TIMER, sendTMSG); | |
sTimer.start(); | |
} | |
public function setTextArea(textArea:TextArea):void{ | |
tArea=textArea; | |
} | |
public function changeSpeed(speed:Number):void{ | |
if(speed>10){ | |
sendMsg("Error: You may only choose a speed between 1 and 10.", tArea); | |
}else if(speed<1){ | |
sendMsg("Error: You may only choose a speed between 1 and 10.", tArea); | |
}else{ | |
sendMsg("Information: Speed was just changed from "+typeSpeed+" to "+speed+".", tArea); | |
typeSpeed=speed; | |
} | |
} | |
private function sendTMSG(e:TimerEvent):void{ | |
if(i!=msgArray.length){ | |
tArea.verticalScrollPosition=tArea.maxVerticalScrollPosition; | |
tArea.text+=msgArray[i]; | |
i++; | |
continueProcess(); | |
}else{ | |
tArea.verticalScrollPosition=tArea.maxVerticalScrollPosition; | |
if(msgArray[i-1]!="."){ | |
tArea.text+="."; | |
} | |
tArea.text+="\n"; | |
i=0; | |
} | |
} | |
private function continueProcess():void{ | |
sTimer.reset(); | |
sTimer.start(); | |
} | |
} | |
} |
Here's the files in the EXACT order it should be in:
http://www.mediafire.com/folder/dnopd8g2tbx8d/AutoTyper Here it is: http://pasteitz.comze.com/Flash%20projects/AutoTyper.swf
No comments:
Post a Comment