You can obtain text stored within any non-static text field. This is particularly useful for input text fields where an app may want to immediately respond to the user's input or collect the information for use later.
This recipe will show you how to capture user input.
From the book's accompanying code bundle, open chapter7\recipe4\recipe.fla
into Flash Professional.
An input text field named submit
is sitting on the stage. Beneath it is a dynamic text field named echo
.
We will write some ActionScript to grab any text that the user enters into the submit
field and display it within the echo
field.
Perform the following steps:
Create a document class named
Main
.Within the class, listen for
FocusEvent.FOCUS_OUT
being dispatched from thesubmit
input field. You will also need to add an import statement for theFocusEvent
class:package { import flash.display.MovieClip; import flash.events.FocusEvent; public class Main extends MovieClip { ...