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

Lesson 12. Nonlinear Flash Interactions > Dynamically Populating the Text Area

Dynamically Populating the Text Area

Now that you have created the text area and created all the button hotspots, you can write the script that makes it functional.

Select Frame 1 of the actions layer, and open the Actions panel. Add the following script below all the existing script:

upperHell_btn.onRelease = function() {
  upperInfo.text="Upper Hell: This map represents the upper reaches of Hell, where Dante begins his travels. The region is bounded by the gates of Hell at the top and the walls of Dis at the bottom, the city that contains those damned for the gravest of sins. Dante begins in Limbo, the first circle, where the Virtuous Pagans reside with neither punishment nor hope of ever seeing God.";


If you want to copy and paste this text string, it is listed under the heading Upper Hell in script_inferno_html.txt.

This piece of code changes the Dynamic Text field to show this string of text when the user clicks the Upper Hell label. The original contents of the dynamic text field disappear.

Choose Control > Test Movie, and click Upper Hell.

The text string dutifully changes, which is pretty cool. What is even more cool is that Flash automatically adds in a scrollbar, to accommodate the text that does not fit in the text area.

Return to the authoring environment, and use the script for upperHell_btn as a model to write five other scripts—one each for the remaining buttons (limbo_btn, lust_btn, and so on). Use the text in script_inferno_html.txt as the source.

Though this step is somewhat repetitive, bear in mind that you are adding quite a bit of functionality to the movie.

Save and test the movie. Click each of the labels to make sure the text area's contents are correctly populated.

As you work through this step, you'll probably notice that if you read one description and scroll down to the bottom, and then click another label, the description remains scrolled at the bottom. It would be more attractive, not to mention usable, if the text area returns to the top every time the user clicks one of the labels.

You can achieve this behavior by adding a simple line of ActionScript to each of the six button functions.

Return to the authoring environment, and in the Actions panel with Frame 1 of the actions layer in the timeline selected, enter the following script before the line that begins upperInfo.text = on each of the buttons.

upperInfo.vPosition = 0;

The property vPosition is built into the TextArea object. It defines the vertical position of the text. By setting it to 0, you ensure that the first line of text appears at the top of the text area.

Save and test the movie.

Try clicking each of the labels and scrolling the text area down to the bottom for each one. Regardless of the current position of the scrollbar, clicking one of the labels should immediately show that label's text, and it should start at the top.



Not a subscriber?

Start A Free Trial

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