Copy link to clipboard
Copied
I have a text input field on the timeline that I want the user to enter specific information in. When that information is correctly entered, I need the timeline to progress.
I successfully used the following AS2, but I cant find corresponding code for AS3
on (keyPress "x") {
gotoAndPlay("s05");
}
Any help on converting this function to AS3 is greatly appreciated.
I'm a little surprised you don't get any error message, but I guess your incomplete conditional doesn't break any laws as written (ended prematurely with a semicolon...
if(pane.text == "x");
gotoAndPlay("s04");
should be...
if(pane.text == "x") gotoAndPlay("s04");
Copy link to clipboard
Copied
You can use an Event.CHANGE listener for the textfield and then test its value in the event handler function to see if it agrees with the required string...
inputtField.addEventListener(Event.CHANGE, testEntry);
function testEntry(evt:Event):void {
if(inputField.text == "whatever"){
// do stuff
}
}
Copy link to clipboard
Copied
Thanks, I modified the code to match the text input file name, and added a line for the action I want:
pane.addEventListener(Event.CHANGE, addEntry);
function addEntry(evt:Event):void {
if(pane.text == "x");
gotoAndPlay("s04");
}
I do not get anny errors, but nothing happens.
Copy link to clipboard
Copied
I'm a little surprised you don't get any error message, but I guess your incomplete conditional doesn't break any laws as written (ended prematurely with a semicolon...
if(pane.text == "x");
gotoAndPlay("s04");
should be...
if(pane.text == "x") gotoAndPlay("s04");
Copy link to clipboard
Copied
Thanks, works perfect!
Copy link to clipboard
Copied
You're welcome