Introduction to ActionScript Tutorial > Display information in a dynamic text box |  |

Display information in a dynamic text box

Dynamic text boxes can display changing content in a Flash movie. You use the Property inspector to create a dynamic text box and assign it a variable name. The value of the variable is displayed in the text field.

In the puzzle.fla file, a dynamic text box displays puzzle piece numbers when a user Shift-clicks a piece. Now you'll assign a variable name for the dynamic text box.

1 | If necessary, choose File > Open and choose the version of the mypuzzle.fla file that you last saved.
| Note: You can also browse to your Flash MX application folder and open Tutorials/ActionScript/Finished/puzzle3.fla. If you do use the puzzle3.fla file, save the file with a new name in your My_Puzzle folder to maintain an unadulterated version of the original file.
2 | In the Timeline, unlock the Piece numbers guide layer if it is locked.
3 | Double-click the Piece number circle movie clip on the Stage under the lower right corner of the puzzle solution area.
| This opens the Piece number circle in symbol-editing mode.
4 | Select the Text layer in the Timeline. On the Stage, click the center of the Piece number circle to select the text field.
5 | If the Property inspector is not open, choose Window > Properties. In the Property inspector, select Dynamic Text from the Text Type pop-up menu.
6 | In the Line Type pop-up menu, verify that Single Line is selected.
7 | Type _root.pieceNumber in the Var text box and press Enter or Return.
| All variables, like functions and movie clips, must be referenced by their paths. The `pieceNumber` variable is declared and updated in the `RotateDisplayOrDrag` function on the main Timeline, but the variable text box is in the Piece number circle Timeline. When you enter the full path to the `pieceNumber` variable, the value updates and displays in the text field on the Stage whenever the variable's value changes on the main Timeline.
8 | Either choose Edit > Edit Document, click the Back button, or click Scene 1 to return to the main Timeline.
9 | Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can revert to earlier versions of the file if necessary.