- assigned_to: nobody --> dfishburn
I'm just now learning Flex 4, and this example straight out of the book I'm learning from (which does compile and run properly, with the Flex 4.1 SDK) doesn't have its ActionScript function discovered:
<?xml version="1.0" encoding="UTF-8" ?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="480" minHeight="480">
<s:states>
<s:State name="State1"/>
<s:State name="cartView"/>
<s:State name="expanded"/>
</s:states>
<fx:Declarations>
<!-- A very simple client-side data model, inline. -->
<fx:Model id="groceryInventory">
<groceries>
<catName>Dairy</catName>
<prodName>Milk</prodName>
<imageName>milk.png</imageName>
<cost>1.20</cost>
<listPrice>1.99</listPrice>
<isOrganic>true</isOrganic>
<isLowFat>true</isLowFat>
<description>Direct from California, where cows are happiest!</description>
</groceries>
</fx:Model>
</fx:Declarations>
<fx:Script><![CDATA[
private function clickedViewCart():void {
this.currentState = "cartView";
}
]]></fx:Script>
<s:controlBarLayout>
<s:HorizontalLayout/>
</s:controlBarLayout>
<s:controlBarContent>
<s:Button label="Checkout" x="20" y="10"/>
<s:Button label="View Cart" x="90" y="10"
click.State1="clickedViewCart()"/>
<mx:Spacer width="100%"/>
<s:Label text="Copyright (C) 2010 My Company"/>
</s:controlBarContent>
<s:HGroup x="0" y="0" width="100%" height="100%" id="bodyGroup">
<!-- "Main" view state. Not visible in cartView. -->
<s:VGroup width="100%" height="150" id="products"
width.cartView="0" height.cartView="0"
visible.cartView="false">
<s:Label text="Milk" id="prodName"/>
<mx:Image scaleContent="true" source="milk.png"
mouseOver="this.currentState='expanded'"
mouseOut="this.currentState='State1'"/>
<s:Label text="$1.99" id="price"/>
<s:Button label="Add to Cart" id="addButton"/>
</s:VGroup>
<!-- "cartView" view state. -->
<s:VGroup height="100%" id="cartGroup" width.cartView="100%">
<s:Label text="Your Cart Total: $"/>
<mx:DataGrid includeIn="cartView" id="dgCart" width="100%">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
<s:Button includeIn="cartView" label="Continue Shopping"
click="this.currentState = ''"/>
</s:VGroup>
</s:HGroup>
<!-- "expanded" view state. -->
<s:VGroup includeIn="expanded" height="100%" id="expanded" x="200" width="100%">
<s:RichText text="{groceryInventory.description}" width="50%"/>
<mx:Label text="Certified Organic"/>
<mx:Label text="Low Fat"/>
</s:VGroup>
</s:Application>