User Guide
Display gift details 33
Add the cart
The next code that you will add creates an instance of the custom Cart class and initializes it.
■ In the Actions panel, add the following code:
var myCart:Cart = new Cart(this);
myCart.init();
This code uses the init() method of the Cart class to add a DataGrid instance to the Stage,
define the columns, and position the DataGrid instance on the Stage. It also adds a Button
component instance and positions it, and adds an Alert handler for the button. (To see the
code for the Cart class
init() method, open the Cart.as file.)
Display gift details
A pop-up window appears in the application when a user clicks a product in the Gift Ideas
section. The pop-up window contains component instances that display information about
the product, including a text description, an image, and the price. To make this pop-up
window, you will create a movie clip symbol and add instances of the Loader, TextArea, Label,
NumericStepper, and Button components. The product detail window for Bouquet of
Flowers Extreme looks like this:
TIP
Press Control+S to save your work and then Control+Enter (or select Control->Test
Movie) to test the application. When you select an offense in the combo box, the data
grid that you created for Gift Ideas should display a subset of gifts to match the
selected offense.