MACROMEDIA FLEX BUILDER-USING FLEX BUILDER Use Manual page 67

Table of Contents

Advertisement

Retrieve the product selection
After detecting the product selected by the user, you must pass the information from the
GridView and ThumbnailView components to the main application. If the user hasn't selected a
product yet, you must specify a default selection.
Open the flexstore_script.as file located in the fbBindings folder.
1.
Enter the following variable declaration at the top of the page:
2.
var selectedItem;
You want to use this variable to store the product selected by the user. The variable is
automatically incorporated in the flexstore.mxml file because the ActionScript file is included
in the file.
Save the ActionScript file.
3.
Switch to the flexstore.mxml file.
4.
In Code view, assign the selected product to the
5.
<local:GridView>
<local:GridView xmlns:local="*"
id="gridView"
dataObject="{catalog}"
change="selectedItem=event.target.selectedItem" />
When a change is detected in the GridView component—for example, when the user clicks a
product in the catalog—the selected product is assigned to the
Locate the
6.
<local:ThumbnailView>
<local:ThumbnailView xmlns:local="*"
id="thumbView"
dataObject="{catalog}"
change="selectedItem=event.target.selectedItem" />
Assign the default product to the
7.
and adding the following property (shown in bold type) in the
<mx:WebService id="catalogWS" serviceName="FlexStoreCatalogWS">
<mx:operation name="getList"
result="selectedItem=catalogWS.getList.result[0]" >
</mx:operation>
</mx:WebService>
The first product in the catalog (
variable so it can be displayed in the ProductDetail component when the user hasn't selected a
product in the catalog yet.
Save the flexstore.mxml file.
8.
tag and adding the following property (shown in bold type):
tag and add the following property (shown in bold type):
selectedItem
getList.result[0]
Tutorial: Binding components to data with Flex Builder
variable by locating the
selectedItem
selectedItem
variable by locating the
<mx:operation>
) is assigned to the
variable.
tag
<mx:WebService>
child tag:
selectedItem
67

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex builder

Table of Contents