Subclassing the mx:Application Tag in Flex
Mike Chambers decided, that now that there is a Free non-commercial license for Flex, to spend a little time playing around with it.
So he rewrote a Robert Crook article using a custom controller class that extended the Flex Application class.
Here it is the code :
---------------------CoffeeApp.mxml---------------------
<?xml version="1.0"?><mc:CoffeeApp xmlns:mc="mc.*" xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Panel title="My First Flex App"> <mx:Label text="Coffee Blends" />
<mx:ComboBox id="coffeeCombo" dataProvider="{coffeeArray}" />
<mx:Text text="Description: {coffeeCombo.selectedItem.data}" width="100%" />
<mx:Button label="Add to Cart" click="addToCart()" />
<mx:List id="cart" />
</mx:Panel>
</mc:CoffeeApp>
---------------------CoffeeApp.as---------------------
//located in /WEB-INF/flex/user_classes/mc class mc.CoffeeApp extends mx.core. Application {
var coffeeArray: Array ;
var cart:mx.controls.List;
var coffeeCombo:mx.controls.ComboBox;
function CoffeeApp() {
coffeeArray = new Array ();
coffeeArray. push ({ label :" Red Sea ", data :" Smooth and Fragrant "});
coffeeArray. push ({ label :" Andes ", data :" Rich and Pungent "});
coffeeArray. push ({ label :" Blue Mountain ", data :" Delicate and Refined "});
}
function addToCart():Void
{ cart. addItem (coffeeCombo.selectedItem. label , coffeeCombo.selectedItem. data ); }
}
All info here.
Great example Mike




















Comments