Weather Widget

An example that uses the Yahoo! Weather API to retrieve weather information. The location and unit to use are sent via flash vars (added to the html). When running your project, you need to add this flash var to your html template: location=your_location (replace your_location).

While this example is simple, it shows two important features:

  1. how to use the PropertyInjector and
  2. how to extend Mate by adding a tag that handles results and fault returned by the weather service. We have an in-depth tutorial about this example and topic.

View Source

Download Source


2 responses so far

  1. Great Framework!!! You also did a great job presenting at WebManiacs this week.

    I'm curious to know..., do you have any suggestions on how to use this sample widget / example without using FlashVars? I guess I'm looking for a code example on how to change the weather data based on an zip code selected in a Flex 3 list box.
  2. Hi Bill,
    Thanks!
    Doing that should be pretty simple, since the main code is implemented in the WeatherEvent.GET EventHandlers. It would be a matter of dispatching the WeatherEvent.GET event with the location you get from your list. Something like this in your view:

    var event:WeatherEvent = new WeatherEvent(WeatherEvent.GET, true);
    event.location = myList.selectedItem (or something like this)
    dispatchEvent(event);

    (You might also need to set the unit property in the event, which I think is either f or c)

Leave a Reply