User Guide
Specify values for input text fields 37
1.
Select File > Publish Settings.
2.
On the Flash tab of the Publish Settings dialog box, select ActionScript 2.0 in the ActionScript
Version pop-up menu, if it’s not already selected.
3.
In the Timeline, click the Components layer to select it.
4.
From the Components panel (Window > Development Panels > Components), drag the
Button component to the Stage and place it over the Calculate guide.
5.
On the Parameters tab of the Property inspector, with the Button component selected, click the
Button text on the Label row, and type Calculate. Then press Enter or Return.
The text that you type in the Label text box is the text that appears on the component.
6.
In the Instance Name text box, enter calculate to provide the button with an instance name.
Declare variables and values for the prices
For your application to multiply the quantity of parts selected by the price of the part, you need
to define a variable for each part in ActionScript. The value for the variable is the cost of the part.
1.
In the Timeline, click Frame 1 of the Actions layer and open the Actions panel (Window >
Development Panels > Actions).
2.
In the Script pane, type //declare variables and values for car part prices.
The parallel slashes (//) indicate that the text that follows is a comment. As a best practice,
always add comments that offer an explanation of your ActionScript.
Note: As you take this lesson, you might find that you’d like to turn off code hints—the tooltips that
prompt you with the correct ActionScript syntax. If so, you can turn off code hinting by clicking the
options menu in the upper right corner of the Actions panel. Select Preferences, and then deselect
Code Hints on the ActionScript tab.
3.
Press Enter or Return and type the following to indicate the cost of each part:
var priceCD = 320;
var priceShocks = 150;
var priceCover = 125;
Specify values for input text fields
You’ll specify values for the input text fields. You’ll use the values when you write ActionScript
that multiplies the quantity and cost values.
1.
In the Script pane, with the insertion point after the text that reads 125;, press Enter or Return
twice and type the following comment:
//set initial values for the quantity text fields
2.
Press Enter or Return, and type the following:
qty1_txt.text = 0;
qty1_txt is the instance name that you gave the first input text field under the QTY column.
.text is a property that defines the initial value in the text field, which you specify is 0.