My Books

  • Follow me on Twitter
My Photo

Subscribe my blog

  • Get this widget from Widgetbox
  • Add to Google
  • RSS FEEDS
  • Enter your Email here to subscribe :



    Powered by FeedBlitz

Blog Widget by LinkWithin

« Passing istances from MXML components | Main | Peldi's Breezo : Building a Video Message Application »

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

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Pistach.io

Speaker at

WebDeveloper's Journal Author

  • My favourite Flash Lite 3 mobile phone
  • Web Developer's & Designer's Journal by Sys Con Media
  • Web Developer's & Designer's Journal Blogger
    Web Developer's & Designer's Journal by Sys Con Media
  • FullAsGoog Aggregator
  • Macromedia WebLogs Aggregator

June 2009

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30