User Guide
76 Chapter 4: Architecting Flex Applications
The CartView_script.as file also contains the following method definitions:
• dataGridChange(selectedItem)
• removeItem()
The CartView.mxml component contains an
<mx:DataGrid> tag for displaying ShoppingCart
items along with several other user-interface components and an
<mx:NumberFormatter> tag for
displaying prices in a specific format. The component is declared in the ShoppingCart.mxml file
using a
<CartView> tag.
The following example shows how the value of the
dataObject property is set to the cart
ShoppingCart object by using curly braces ({ }) to bind data:
...
<ShoppingCart id="cart"/>
...
<CartView id="cartView" dataObject="{cart}"
width="370" height="{549-productDetail.height}"
itemSelected="selectedItem=event.target.selectedItem"
checkOut="changeView('checkout')" vScrollPolicy="off"/>
ProductThumbnail
The ProductThumbnail object defines a custom cell renderer used by the ThumbnailView object.
You use a cell renderer to manipulate and display custom cell content for each of row of a list-
based component. In this example, you use ProductThumbnail to define an image and two labels
in each cell of a TileList control.
The ProductThumbnail component contains the following properties defined in an
<mx:Script> tag:
• var _filteredOut
• var dataObject
The
_filteredOut property indicates whether to dim a ProductThumbnail’s appearance based
on the currently selected price range. The
dataObject property stores catalog data.
The component contains the following methods defined in an
<mx:Script> tag:
• setValue()
• set filteredOut()
• hideWhenChanging()
The following example from the ThumbnailView.mxml file shows how the
dataObject property
is set to the catalog data for the
currentItem in the catalog object, and the cell renderer is set to
the ProductThumbnail object:
...
<mx:Script>
<![CDATA[
var dataObject;
var selectedItem;
]]>
</mx:Script>