Highlighted

Any keypress event =goto next frame

New Here ,
Jul 11, 2019

Copy link to clipboard

Copied

I'm trying to create a keypress event that would give the impression of somebody working on a keyboard and having their document appear onscreen real time as they type. No matter what key they press, they correct letters come up. I have received code to use and have tried snippets but Animate seems buggy (or maybe I am) but it doesn't seem to work.

​Basically I need any key pressed to move the playhead forward:

(snippet)​:

stop();

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);

function fl_KeyboardDownHandler(event:KeyboardEvent):void

{

nextFrame();

}

​(previous script):

stop();stage.addEventListener(KeyboardEvent.KEY_DOWN, changeSection);

function changeSection(event:KeyboardEvent):void {

nextFrame();

}

​nothing occurs.

​thank you in advance

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

click the stage with your mouse and then type.  any problems?

Views

326

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Any keypress event =goto next frame

New Here ,
Jul 11, 2019

Copy link to clipboard

Copied

I'm trying to create a keypress event that would give the impression of somebody working on a keyboard and having their document appear onscreen real time as they type. No matter what key they press, they correct letters come up. I have received code to use and have tried snippets but Animate seems buggy (or maybe I am) but it doesn't seem to work.

​Basically I need any key pressed to move the playhead forward:

(snippet)​:

stop();

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);

function fl_KeyboardDownHandler(event:KeyboardEvent):void

{

nextFrame();

}

​(previous script):

stop();stage.addEventListener(KeyboardEvent.KEY_DOWN, changeSection);

function changeSection(event:KeyboardEvent):void {

nextFrame();

}

​nothing occurs.

​thank you in advance

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

click the stage with your mouse and then type.  any problems?

Views

327

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 11, 2019 0
Adobe Community Professional ,
Jul 11, 2019

Copy link to clipboard

Copied

click the stage with your mouse and then type.  any problems?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
New Here ,
Jul 11, 2019

Copy link to clipboard

Copied

nothing comes up

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
Adobe Community Professional ,
Jul 11, 2019

Copy link to clipboard

Copied

what do you mean by 'nothing comes up'?  you're not going to see anything unless you have a multiframe main timeline with different content in each frame.

if you want the text to appear in a textfield, you must create the textfield and the code to add text to it:

stop();

var alphaS:String="abcdefghijklmnopqrstuvwxyz";

var tf:TextField=new TextField();

addChild(tf);

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);

function fl_KeyboardDownHandler(event:KeyboardEvent):void

{

tf.appendText(alphaS.charAt(event.charCode-97));   // this will get you started with lowercase letters.

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
New Here ,
Jul 11, 2019

Copy link to clipboard

Copied

I responded that it was correct. Once I clicked the stage the keyboard was live and i could initiate the playhead with any keystroke.

Now I need to be able to get one letter per input so that it gives the appearance of someone typing a document that is predetermined by me. Every key forwards the playhead I suppose to display the next letter. One press per letter, speed determined by the user, preferably with a blinking cursor to lead the way.

I had this down pat at one point, but it has been years since.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
Adobe Community Professional ,
Jul 11, 2019

Copy link to clipboard

Copied

read message 3.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
New Here ,
Jul 11, 2019

Copy link to clipboard

Copied

I input the code  provided. It allows me to type anchored to the object i attached it to. How ever, i want to be able to type any 12 letters bbbbbbbbbbbb for example and have it display as predefined text. So any keystroke (as an example):bbbbbbbbbbbb = how are you? (as an example)

also whatever i type using the code displays twice on the stage.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
Adobe Community Professional ,
Jul 11, 2019

Copy link to clipboard

Copied

create a new fla.

copy the message 3 code and paste into frame 1 of your 1 frame fla.

test.

any problem?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
New Here ,
Jul 11, 2019

Copy link to clipboard

Copied

i copied into a one frame fla. when i click on the stage and type it shows the keys i press in the upper left corner of the stage, in a very small font.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2019 0
Adobe Community Professional ,
Jul 12, 2019

Copy link to clipboard

Copied

any problem?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 12, 2019 0
New Here ,
Jul 15, 2019

Copy link to clipboard

Copied

i copied into a one frame fla. when i click on the stage and type it shows the keys i press in the upper left corner of the stage, in a very small font.

I am trying to re-create something I did years ago. The user types on the keyboard (it doesn't matter what they type), the input does not reflect the output. I have predefined lines from a document and I want them to be able to type without any errors. I imagine that I have each letter separated into a keyframe and that any key press will give the appearance that it is being typed live and accurately. The text needs to be larger and positioned as it would in a word doc.

I also need to have a blinking cursor preceding each letter as though it was actually being typed.

The code from message 3 allows me to type and for my input key, the matching letter appears in the upper left and very small. I have no cursor.

I am going to replace the lower case letters in message three with the text that I want to come, however what comes up is whatever I input.

Thanks in advance.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 15, 2019 0
Adobe Community Professional ,
Jul 15, 2019

Copy link to clipboard

Copied

use:

stop();

var preferredS:String='the quick brown fox';  // use whatever you like

var tf:TextField=new TextField();

addChild(tf);

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);

function fl_KeyboardDownHandler(event:KeyboardEvent):void

{

if(tf.length<preferredS.length){

tf.appendText(preferredS.indexOf(tf.length));

}

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 15, 2019 0
New Here ,
Jul 15, 2019

Copy link to clipboard

Copied

II seem to be so so so close now.

I have it so that any key forwards one keyframe and spells out my text line.

I have a cursor that also moves in sync with the letters being typed.

I am lapsing on how the get my cursor layer to blinking as it waits for each new keypress though.

Any suggestions?

Thank you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 15, 2019 0
New Here ,
Jul 30, 2019

Copy link to clipboard

Copied

Hello,

thanks again for all your help.

My file used to return to frame 1 upon pressing return.

It no longer does that. Any thoughts?

This code doesn't allow me to rest with return:

stop();

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);

function fl_KeyboardDownHandler(event:KeyboardEvent):void

{

nextFrame();

}

THIS ONE DOES RESET UPON "RETURN":

stop();

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);

function fl_KeyboardDownHandler(event:KeyboardEvent):void

{

nextFrame();

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2019 0
Adobe Community Professional ,
Jul 30, 2019

Copy link to clipboard

Copied

what do you mean by "reset upon 'return'"?

do you want something to happen when the return key is pressed?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2019 0
New Here ,
Jul 30, 2019

Copy link to clipboard

Copied

I want the playhead to return to the beginning of the animation to reset the scene.

would you happen to also know of a process that would take each letter of a paragraph and turn them into an object that could be placed into its own keyframe procedurally?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2019 0
New Here ,
Jul 30, 2019

Copy link to clipboard

Copied

id really like to be able utilize a different method to simulate the typing of this sort of text amount ( i am currently adding one letter to keyframe, I seem to recall being able to add a live text box somewhere and then have it access the embedded text from within the action script:

Wi-Fi can provide you with added coverage in places where cell networks don't always work - like basements and apartments. No roaming fees for Wi-Fi connections also means you stay connected while travelling the world.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2019 0