<!-- Provide a ZIP code in a TextInput control. -->
<mx:TextInput id="zip" width="200" text="Zipcode please?"/>
<!-- Call the web service operation with a Button click. -->
<mx:Button width="60" label="Get Weather"
click='WeatherService.GetWeather.send()'/>
<!-- Display the location for the specified ZIP code. -->
<mx:Label text="Location:"/>
<mx:TextArea text="{WeatherService.GetWeather.result.Location}"/>
<!-- Display the current temperature for the specified ZIP code. -->
<mx:Label text="Temperature:"/>
<mx:TextArea text="{WeatherService.GetWeather.result.CurrentTemp}"/>
</mx:Panel>
</mx:Application>
The following figure shows the application rendered in a web browser window:
For more information about using data services, see Chapter 31, "Managing Data in Flex," in
Developing Flex Applications.
Storing and validating application-specific data
You can use a data model to store application-specific data. A data model is an ActionScript object
that provides properties for storing data, and optionally contains methods for additional
functionality. You can declare a simple data model that does not require methods in an
tag or
<mx:Model>
data model. Flex includes a set of standard validator components. You can also create your own.
The following example shows an application that contains TextInput controls for entering
personal contact information; a data model, represented by the
contact information; and validator components for validating that the expected type of data is
entered in the TextInput fields. Validation is triggered automatically when data binding occurs. If
validation fails, the user receives immediate visual feedback.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
<mx:Panel title="My Application" marginTop="10" marginBottom="10"
marginLeft="10" marginRight="10" >
30
Chapter 2: Using MXML
tag. You can use validator components to validate data stored in a
<mx:XML>
tag, for storing the
<mx:Model>
Need help?
Do you have a question about the FLEX-GETTING STARTED WITH FLEX and is the answer not in the manual?
Questions and answers