Add the cart

The next code that you will add creates an instance of the custom Cart class and initializes it.

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.)

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.