Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Draws a graphic which will be used as a button. Alpha is 0, meaning it is transparent.
- function DrawButton() {
- var ButtonSprite:Sprite = new Sprite();
- ButtonSprite.graphics.beginFill(0xff000,1);
- ButtonSprite.graphics.drawRect(0,0,200,30);
- ButtonSprite.graphics.endFill();
- ButtonSprite.alpha = 0;
- return ButtonSprite;
- }
- // Creates the format for the text which will appear in the text box.
- function CreateFormat(size:int, Font:String) {
- var CreateFormat:TextFormat = new TextFormat();
- CreateFormat.size = size;
- CreateFormat.font = Font;
- return CreateFormat;
- }
- // Creates a button.
- function CreateButton (OriginX:int, OriginY:int, Width:int, Height:int) {
- var CreateButton:SimpleButton = new SimpleButton();
- CreateButton.overState = CreateButton.downState = CreateButton.upState = CreateButton.hitTestState = DrawButton();
- CreateButton.x = OriginX;
- CreateButton.y = OriginY;
- CreateButton.width = Width;
- CreateButton.height = Height;
- return CreateButton;
- }
- var j:int = 0; // Itterative loop-counter.
- var i:int = 0; // Another itterative loop-counter.
- var MessageCount:int = 0; // Indicates the total number of messages in a TextOut function call.
- var MessageEnd:int = 0; // Indicates if the final message in a TextOut function call has been displayed.
- var MessageStatus:int; // Indicates whether the current message is being letterized.
- var StringsArray:Array = new Array(); // An array that contains all the messages as strings.
- var LettersArray:Array = new Array(); // An array that contains the current message strings letters.
- var LetterTimer:Timer = new Timer(125); // A timer that allows letterization to be delayed by a specified amount of miliseconds.
- var MessageButton:SimpleButton = CreateButton(0, 549, 432, 218); // Creates the button that skips or advances messages.
- var MessageTextField:TextField = new TextField(); // The text field inside which the message is displayed.
- var MessageFormat:TextFormat = CreateFormat(25, "Century Gothic"); // A format, which is applied to our text field, on the next line.
- MessageTextField.setTextFormat(MessageFormat); // Applies MessageFormat to MessageTextField.
- function Letterize(){
- if (MessageEnd == 1) {
- removeChild(MessageButton);
- removeChild(MessageTextField);
- MessageButton.removeEventListener(MouseEvent.MOUSE_DOWN,onMessageButtonClick);
- } else {
- MessageStatus = 0;
- addChild(MessageTextField);
- addChild(MessageButton);
- MessageTextField.wordWrap = true;
- MessageTextField.selectable = false;
- MessageTextField.width = 392;
- MessageTextField.x = 20;
- MessageTextField.y = 549;
- MessageTextField.height = 218;
- MessageTextField.text="";
- j=0;
- LetterTimer.start();
- LetterTimer.addEventListener(TimerEvent.TIMER, update);
- function update(TimerEvent){
- MessageTextField.appendText(LettersArray[j]);
- MessageTextField.setTextFormat(MessageFormat);
- j++;
- if(j==LettersArray.length){
- MessageStatus = 1;
- LetterTimer.stop();
- }
- }
- }
- }
- function TextOut(... arguments){
- MessageEnd = 0;
- MessageCount = arguments.length ;
- i = 0;
- for (i = 0; i < MessageCount; i++) {
- StringsArray.push(arguments[i]);
- }
- i = 0;
- LettersArray = StringsArray[i].split("");
- Letterize();
- MessageButton.addEventListener(MouseEvent.MOUSE_DOWN,onMessageButtonClick);
- function onMessageButtonClick(evt:MouseEvent):void{
- if(MessageStatus == 1 && i == MessageCount - 1) {
- MessageEnd = 1;
- Letterize();
- MessageButton.removeEventListener(MouseEvent.MOUSE_DOWN,onMessageButtonClick);
- } else if (MessageStatus == 0) {
- MessageTextField.text = StringsArray[i];
- MessageTextField.setTextFormat(MessageFormat);
- LetterTimer.stop();
- LetterTimer.reset();
- MessageStatus = 1;
- } else if (MessageStatus == 1) {
- i++;
- //removeChild(MessageTextField);
- LetterTimer.stop();
- LetterTimer.reset();
- j=0;
- LettersArray = StringsArray[i].split("");
- Letterize();
- }
- }
- }
- TextOut("Wow. Whoa. That is some group of people. Thousands.", "So nice, thank you very much. That's really nice. Thank you. It's great to be at Trump Tower. It's great to be in a wonderful city, New York.", "And it's an honor to have everybody here. This is beyond anybody's expectations. There's been no crowd like this.", "And, I can tell, some of the candidates, they went in. They didn't know the air-conditioner didn't work. They sweated like dogs.", "They didn't know the room was too big, because they didn't have anybody there. How are they going to beat ISIS? I don't think it's gonna happen.", "Our country is in serious trouble. We don't have victories anymore. We used to have victories, but we don't have them. ");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement