• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 17. Text: Add Text to a Document > View ActionScript for the dynamic te...

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.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint