Displaying the Username Dynamically
Before accessing this quiz, the user must enter her or his name in the log-in screen. Inside the Flash movie, the username is displayed as follows: "Welcome, username." Currently, the username is hard-coded so that no matter how the user signs in, the word "username" will display in the movie. In this task, you'll set up Flash to display the name dynamically. For this step to work properly, you'll need to work in the ColdFusion file in which this Flash movie will be loaded.
1. | Click the word username in Frame 1. Use the Property inspector to change its type from Static Text to Dynamic Text. Give it an instance name of username_txt . |
By changing the word's type to dynamic and giving it an instance name, you can now change the contents of the text field on the fly using ActionScript.[View full size image]

2. | Return to the Actions panel and click Frame 1 of the actions layer in the timeline . |
You should see the script you typed up in the previous task. You'll now add to that.
3. | At the bottom of the current script, add the following code :var username:String; |
In the first line you declare a new variable, called username, and tell Flash that it's a string (that is, text as opposed to a number or an array of data, for example). ActionScript 2.0, introduced in Macromedia Flash MX 2004, enables developers to specify the variable type of all their variables, which helps with debugging. Notice that you're not assigning a value to this variablemore on that in a moment.In the second line, you're populating the content of username_txt with the value of username. This might surprise you, since you still haven't assigned a value to the username variable. The reason you don't need to assign a value to this variable is that one will have already been assigned; it will be passed into the Flash movie from ColdFusion. In other words, as soon as the movie loads it will have a username variable with a value (an email address) already available. Thus, in this code all you're doing is officially declaring the variable and making its value appear onscreen via the username_txt text field instance.
4. | Update the comment just above the script you added in Step 3 with the following information :* Populates username_txt with the value of the username variable |
Make sure you put this line inside the comment block!
5. | Choose Control > Test Movie, and close the movie after it starts playing . |
Selecting Text Movie is the quickest way to generate a SWF based on the current state of the FLA. You aren't really testing the movie, so you can close it as soon as it opens.Obviously, the movie is far from complete, but it's sufficient to put in a ColdFusion document.