Lesson 9. Using Custom Events


What You Will Learn

In this lesson, you will:

  • Understand the benefits of a loosely coupled architecture

  • Dispatch events

  • Declare events for a component

  • Identify the need for custom event classes

  • Create event subclasses

  • Create and use a CategoryEvent class

  • Create and use a ProductEvent class

  • Use ProductEvent to remove a product from the cart

  • Use ProductEvent to add a product to the cart

  • Use event bubbling

Approximate Time

This lesson takes approximately 2 hours to complete.

Lesson Files

Media Files:

None

Starting Files:

Lesson09/start/DataEntry.mxml

Lesson09/start/EComm.mxml

Lesson09/start/as/ecomm.as

Lesson09/start/managers/CategorizedProductManager.mxml

Lesson09/start/valueObjects/Category.as

Lesson09/start/valueObjects/Product.as

Lesson09/start/valueObjects/ShoppingCart.as

Lesson09/start/valueObjects/ShoppingCartItem.as

Lesson09/start/views/dataEntry/UpdateDeleteProd.mxml

Lesson09/start/views/dataEntry/AddProduct.mxml

Lesson09/start/views/ecomm/Cart.mxml

Lesson09/start/views/ecomm/CategoryView.mxml

Lesson09/start/views/ecomm/FoodList.mxml

Lesson09/start/views/ecomm/GroceryDetail.mxml

Completed Files:

Lesson09/complete/DataEntry.mxml

Lesson09/complete/EComm.mxml

Lesson09/complete/as/EComm.as

Lesson09/complete/events/CatEvent.as

Lesson09/complete/events/ProductEvent.as

Lesson09/complete/managers/CategorizedProductManager.mxml

Lesson09/complete/utils/Util.as

Lesson09/complete/valueObjects/Category.as

Lesson09/complete/valueObjects/Product.as

Lesson09/complete/valueObjects/ShoppingCart.as

Lesson09/complete/valueObjects/ShoppingCartItem.as

Lesson09/complete/views/dataEntry/UpdateDeleteProd.mxml

Lesson09/complete/views/dataEntry/AddProduct.mxml

Lesson09/complete/views/ecomm/Cart.mxml

Lesson09/complete/views/ecomm/CategoryView.mxml

Lesson09/complete/views/ecomm/FoodList.mxml

Lesson09/complete/views/ecomm/GroceryDetail.mxml

In the last few lessons, you worked with events from built-in objects, such as the click of a Button or the change of a List. As you get deeper into application development, you will often find a need to dispatch your own custom events. In this lesson, you will learn how to create an event object, set the metadata for the object, and dispatch it.

This lesson presents an overview of how to dispatch custom events within your application, and how to create new Event classes by creating a subclass of Event.

The shopping cart allows you to add and remove items.




Adobe Flex 2.Training from the Source
Adobe Flex 2: Training from the Source
ISBN: 032142316X
EAN: 2147483647
Year: 2006
Pages: 225

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net