MACROMEDIA FLEX BUILDER-USING FLEX BUILDER Use Manual page 73

Table of Contents

Advertisement

Activate the Delete button
The final step in this tutorial is to active the Delete button in the shopping cart area so the user
can remove items from the cart.
Switch to the CartView.mxml file.
1.
In Code view, enter the following function in the
2.
<mx:Script>
var dataObject:ShoppingCart;
function removeItem() {
if (dg.selectedIndex!=undefined)
dataObject.removeItemAt(dg.selectedIndex);
}
</mx:Script>
The function calls the
Locate the
3.
<mx:Button>
two properties (shown in bold type):
<mx:Button label="Delete"
width="75"
enabled="{dg.selectedItem!=null}"
click="removeItem()" />
The Delete button is enabled only when a user selects an item in the shopping cart. When the
user clicks the button when an item is selected, the
Save the CartView.mxml file.
4.
Switch to the flexstore.mxml file and click Run on the Document toolbar to test the Delete
5.
button in the browser embedded in Flex Builder.
Add items to the shopping cart, select an item in the cart, and click the Delete button. The
item should be removed from the cart.
This completes the tutorial on Flex data bindings. If you want, you can continue experimenting
with Flex Builder and Flex development by adding more features to your Flex Store application.
For example, you could add drag-and-drop support to let the user drag a product from the catalog
view to the product detail view.
method of the cart object.
remoteItemAt
tag for the Delete button near the end of the file and add the following
Tutorial: Binding components to data with Flex Builder
tag (shown in bold type):
<mx:Script>
function is called.
removeItem()
73

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex builder

Table of Contents