Yahoo API’s - A Weather Widget

Well I finally got around to building something with the new Yahoo Flex API’s. In this example, I am using the Yahoo Weather API to display a few of the many weather properties that are available via this API. This application uses shared objects to store the user preferences, the Timer class to fetch new results per the user refresh setting, as well as the Distortion Effects from Alex Uhlman.
Here is the application running in the browser
Here is the same application packaged in an Apollo AIR file.




April 24th, 2007 at 8:35 pm
Would you share the code for your weather widget. I was going through Yahoo’s example and was running into errors. Nice sample, by the way.
Thanks,
Trace
April 24th, 2007 at 8:43 pm
What kind of issues were you having?
June 1st, 2007 at 12:37 am
I have been trying to find a working example of the Timer object to refresh and html block in my little Apollo webcam app. Can you share a little bit of what you did? Thanks.
June 14th, 2007 at 8:23 pm
So, it’s taken me a while to get back to this. The problems I am having are related to getting the sunrise & sunset times to display and also I am having trouble getting the larger Weather Icon(that you see on Yahoo’s site and the Apollo example) to show vs. the small icon as viewed in your example. Any suggestions would be helpful.
Thanks,
T
June 15th, 2007 at 7:33 am
dbtahoe,
The Timer simple gets started upon creationComplete of the application and will run every 6000 milliseconds (1 minute) at which time it will call the timerHandler function. Here are the 2 functions:
June 15th, 2007 at 7:46 am
With weather being the com.yahoo.webapis.weather.Weather object, the sunrise and sunset would be displayed with the following code:
weather.current.astronomy.sunrise
weather.current.astronomy.sunset
The image is display with this code:
weather.current.imageURL
June 18th, 2007 at 7:48 pm
OK - I was trying your suggestion previously, but I wasn’t taking it as far as I needed to. After some addiotanl trial and error I found that beyond the “weather.current.astronony.sunrise” you then have to add the appropriate UTC and “toString()” tags for hours and minutes seperately.
My next task is to produce the large weather icon vs. the small.
Thank you,
Trace
July 15th, 2007 at 5:28 pm
Hi,
I’m wondering how you get all your seperate data?
I have the following code:
[code]
private var weather:WeatherService = new WeatherService();
private function init():void
{
weather.getWeather(”90210″, “c”);
weather.addEventListener(”WeatherLoaded”, showWeer);
}
private function showWeer(e:WeatherResultEvent):void
{
if(e.success == true)
{
}
else
{
trace(e.data);
imgWeather.source = “http://l.yimg.com/us.yimg.com/i/us/we/52/32.gif”;
}
}
[/code]
init function gets called on creationcomplete, as you see there are some weird things here, first I allways get success == false, but when i trace e.data, i get a long string with all the correct info in it…but i can’t access any, because it’s a string? i wonder if there is no way around to get an array or something returned?
I hope you can help me out, because the info on the yahoo api site really sucks big time
July 24th, 2007 at 11:02 am
Can you add a feature to grab past weather info?
February 3rd, 2008 at 11:44 pm
I know a lot of people would appreciate a more detailed example, or source.
I’ve been banging my head against getting solid Weather data in flex for hours.
I haven’t found a lot of usable information. There isn’t any usable code on Yahoo’s site either! Could you give us something, anything that’s usable?