24
Common Scripting Tasks
5.
Select the first (top-most) text field, and in the Property inspector, type
item_1
in the Var
text box.
This variable name corresponds to the name of the first variable defined in the data.txt file
you created previously (
item_1=Hello
).
6.
In the same manner as described in the previous two steps, give the remaining four text
fields the variable names
item_2
,
item_3
,
item_4
, and
item_5
.
7.
Shift-select each text field so that they’re all selected, and select Modify > Convert To
Symbol.
8.
In the Convert to Symbol dialog box, select Movie Clip as the symbol type and click OK.
9.
Select the movie clip you just created and, in the Property inspector, type
data_clip
in the
Instance Name text box.
10.
In the Timeline, select Frame 1 of the Actions layer and open the Actions panel
(Window > Actions).
11.
Type the following code in the Actions panel:
loadVariables("data.txt", "data_clip");
12.
Save your changes (File > Save) and test the application in the emulator (Control > Test
Movie).
You should see each text field populated with the data in the text file, as the following
figure shows:
Summary of Contents for FLASH 8-LEARNING FLASH LITE 1.X ACTIONSCRIPT
Page 1: ...Learning Flash Lite 1 X ActionScript ...
Page 4: ...4 Contents ...
Page 8: ...8 About Flash Lite 1 x ActionScript ...