Adobe Flash

View ActionScript for the dynamic text field

You can view the ActionScript that loads text from the external text file into the dynamic text field. This script uses LoadVars actions to load the safetyfeatures.txt content in the newFeatures text field.

1.
In the Timeline, select Frame 1 of the Actions layer.

2.
Select Window > Actions, or press F9.

The ActionScript appears as follows:

// Load text as variable and assign it to the

// dynamic text field

var features_lv:LoadVars = new LoadVars();

features_lv.onLoad = onText;

features_lv.load("safetyfeatures.txt");

function onText(success:Boolean) {

  if (success) {

    newFeatures_txt.text = features_lv.safetyfeatures;

  } else {

    newFeatures_txt.text = "unable to load text file.";

  }

}

3.
Close the Actions panel.

Test the SWF file

Save and test the document to ensure that the dynamic text loads correctly.

1.
Select File > Save; then select Control > Test Movie.

In the SWF file window, text from the external text file should appear in the dynamic text field that you created. (If the text does not appear as expected, check that you entered the instance name correctly: newFeatures_txt. Also check that you saved your copy of the practice file in the same folder as the original text_start file.)

2.
Type in the input text fields.

3.
When you finish testing the file, close the SWF file window.

by BrainBellupdated
Advertisement: