Flash : Updatable text fields
Contents ]
David Einhorn

Assigning the Variables to the three Text Fields

The content of each field is supplied by means of a variable (date, title and info). We have to assign these variables the values from the text file. In the date field, we want to display the contents of the txtdate variable. But there is no reason to panic, this is quite simple!

  1. Insert a new blank keyframe in the second frame of the Script layer.

  2. Edit the properties of this second keyframe and select the Actions tab.

  3. Click on the + button of the tab and add a Set Variable action.

  4. Enter date in the Variable field in the right-hand panel of the window.

  5. By doing so, you specify the variable in which the text should be placed.

  6. Enter txtdate in the Value field and select the Expression type by clicking on the button located on the right-hand side of the field.

  7. By selecting the Expression type, we are telling Flash that it must interpret txtdate as a script element. If you had opted for the String Literal type, it would not use txtdate as a variable but rather as a content to be displayed.

Now you just need to repeat steps 3 to 5 for the other text fields, in order to assign the appropriate contents to the title and info variables.

You can add a last blank keyframe at the end of your movie. Display its properties and add a Stop action to pause the playback of the movie after loading. This prevents the playback from jumping back to the first frame and continually loading the field contents.



Figure 5: Defining the values of the variables

You can use this small animation sequence in other movies to display the latest news about your site. But while you are at it, why not continue to explore the properties of the text fields associated with the variables? There are numerous application options. With a bit of skill, you can create a calculator but, more importantly, interface your animations with PHP or CGI scripts. A last glance at the results of this workshop.




  1   2   3   4   5