Calendar

April 2007
M T W T F S S
« Mar   May »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Tag Cloud

Categories

Archives

Highest Rated

Most Viewed

Recent Posts

Recent Comments


« Apollo Cheat Sheets | Main | Same Apollo app HTML vs Flex versions »

Yahoo API’s - A Weather Widget

By Rich Tretola | April 12, 2007Print This Post Print This Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
825 views

 weatherwidget.jpg

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.

Share/Save/Bookmark

Topics: Adobe AIR, Flex 2 |

15 Responses to “Yahoo API’s - A Weather Widget”

  1. Trace Says:
    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

  2. everythingflex Says:
    April 24th, 2007 at 8:43 pm

    What kind of issues were you having?

  3. dbtahoe Says:
    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.

  4. Trace Says:
    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

  5. everythingflex Says:
    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:

    1. private var myTimer:Timer;
    2.  
    3. private function startTimer():void{
    4.     myTimer = new Timer(6000, 0);
    5.         myTimer.addEventListener("timer", timerHandler);
    6.         myTimer.start();
    7.         trace("timer started");
    8. }
    9.  
    10. private function timerHandler(event:TimerEvent):void{
    11.         trace("timer run");
    12.     getWeather();
    13. }
  6. everythingflex Says:
    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

  7. Trace Says:
    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

  8. Frederik Jacques Says:
    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 :-)

  9. Johnny Says:
    July 24th, 2007 at 11:02 am

    Can you add a feature to grab past weather info?

  10. Brian McManus Says:
    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?

  11. nellehs Says:
    July 31st, 2008 at 10:46 pm

    hi, I see the application; it is great.
    However, I do not understand how the timer refresh works. Can you explain?
    Thanks

  12. everythingflex Says:
    August 1st, 2008 at 4:44 am

    The timer is simply used to poll the weather service to get updated weather information.

  13. Lora Says:
    August 7th, 2008 at 4:36 am

    Same here with Brian. Still can’t find useful info regarding with using the Yahoo! Weather API.

    Yahoo’s site isn’t helpful, with this, even.

  14. Rich Tretola Says:
    August 7th, 2008 at 7:48 am

    To get the IpAddress please see this post.

  15. Rich Tretola Says:
    August 7th, 2008 at 8:53 am

    I have enabled the source for this application. Here is the link:
    Source View

    Please note that I don’t think the AstraWebAPIs.swc is officially supported by Yahoo.

Comments