TAILIEUCHUNG - Adobe Flex 4 Training from the Source Volume 1 phần 7

Tiếp theo, bạn sẽ tạo ra một lớp dịch vụ tương tự CategoryService tải và quản lý các sản phẩm, và bạn sẽ loại bỏ logic từ các ứng dụng chính. 13 Đóng tất cả các tập tin mở. Kích chuột phải vào thư mục dịch vụ và sau đó chọn ActionScript Class mới. Trong hộp thoại New Class ActionScript, thiết lập Tên như ProductService và thiết lập | 280 LESSON 11 Creating and Dispatching Events 3 Add an fx Metadata tag to this class. Inside it declare that will dispatch two events named addProduct and removeProduct. Indicate that both events will be of type . fx Metadata Event name addProduct type Event name removeProduct type fx Metadata This DataGroup is going to use the renderer. As you declared earlier that itemRenderer will dispatch two bubbling events addProduct and removeProduct. As you saw in the EventLab when an event bubbles you can listen for the event on any of the parent instances. In this case you will listen for the addProduct and removeProduct events on the ProductList. 4 Save the ProductList class. It should read as follows xml version encoding utf-8 s DataGroup xmlns fx http mxml 2009 xmlns s library flex spark xmlns mx library flex mx itemRenderer s layout s VerticalLayout s layout fx Declarations -- Place non-visual elements . services value objects here-- fx Declarations fx Metadata Event name addProduct type Event name removeProduct type fx Metadata s DataGroup Using the ProductList Component You will now replace the DataGroup in your ShoppingView with your new ProductList component. 1 Open the file and locate the DataGroup on approximately line 40. 2 Directly below the DataGroup add a ProductList component. If you used code-completion Flash Builder automatically added a components name space on your behalf. If you did not you will need to add this namespace manually. components ProductList Download from Creating and Using the ProductEvent Class 281 3 Many of the properties on the DataGroup will be the same on your new ProductList. Copy the width height and visible properties for both the normal and cartView state to your ProductList tag. components .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.