Skip to main content
Participating Frequently
November 28, 2013
Question

Auto Type by keystroke AS 2 or 3 Help

  • November 28, 2013
  • 1 reply
  • 588 views

Hoping someone can assist me as what I require is too advanced for my skill set. Need an action/class/variable? that enables a text area to reveal text by pressing any keys on the keyboard. The key pressing could reveal 1, 2 or 10 characters each stroke and the sentence or paragraph revealed can also be customised.

The effect makes it look like you can type extra fast and not make any mistakes as what you are typing is already pre set. A blinking cursor would also need to be generated.

Hoping someone can help. I've used this effect a lot -

http://flashexplained.com/text/creating-a-screen-with-autotyping-readout-text/

but want key strokes to control the amount of characters revealed not a button that plays out a string of text like the link shown.

Thanks

This topic has been closed for replies.

1 reply

Inspiring
November 28, 2013

Basic version:

//The number on the numpad the user presses controls the autotype speed (1:= slowest...9:=fastest)

import flash.events.Event;

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);

var str:String = "Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. Pityful a rethoric question ran over her cheek, then";

var active:Boolean = false;

var pointer:Number = 0;

var keynumber:int = 0;

function enterFrameHandler(e:Event):void

{

    if (active)

    {

        type(keynumber);

    }

}

function keyDownHandler(e:KeyboardEvent):void

{

    trace(String.fromCharCode(e.charCode));

    keynumber = int(String.fromCharCode(e.charCode));

    active = true;

}

function keyUpHandler(e:KeyboardEvent):void

{

    trace(String.fromCharCode(e.charCode));

    active = false;

}

function type(_number:int):void{

       //stop when textend has been reached

        if (pointer<str.length)

        {

            pointer += _number;

            //textfield instance tf on stage

            tf.text = str.substr(0,pointer);

        }

}

Participating Frequently
November 28, 2013

Thanks moccamaximum for replying so quickly! Do you mind helping with the set up of the file?

Do I need to make the text area a movie clip ? Or is the instance name of tF OK.........assume that's what it should be. Also doI set the text as dynamic with multiline checked?

Thanks again for your help.

Inspiring
November 28, 2013

Do I need to make the text area a movie clip ?

NO

Or is the instance name of tF OK.........assume that's what it should be.

YES

Also doI set the text as dynamic with multiline checked?

YES