View Full Version : Flash Widget, Yahoo weather
ruiganga
May 5th, 2009, 11:32 PM
HI
I am trying to make a flash widget using yahoo weather API. Since it uses RSS I thought it was simples but I am stuck. I just don't know how to extract info inside this xml line:
<yweather:units temperature="C" distance="km" pressure="mb" speed="kph"/>
my complete code is:
var location_id:String='POXX0022';
var grades:String='c';
var url:String="http://weather.yahooapis.com/forecastrss?p="+location_id+"&u="+grades;
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(url));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseRSSNews(xmlData);
}
function ParseRSSNews(rssNewsInput:XML):void {
trace("XML Output");
trace("------------------------");
trace(rssNewsInput.channel);
trace("------------------------");
trace(rssNewsInput.channel.description);
trace("------------------------");
// this is the line that traces NOTHING
trace(rssNewsInput.channel.units);
}
I hope someone can help me :)
StingRay5
May 21st, 2009, 08:18 AM
Hi Ruiganga,
I was busy with something similar, at first I was trying to read the rss feed, which worked in some degree. I also got stuck at the part where the XML uses the ":". But then I came across the Yahoo! ASTRA Flash API's. These also include the Weather service of Yahoo!
Click the link:
http://developer.yahoo.com/flash/astra-webapis/
I'm just getting into it, but take a look, and you'll see it's good to use in Flash.
Let me know if it worked out for you as well!
Keep you posted!
Cheers,
Do
UPDATE:
Hi Ruiganga, I found the following link: http://joshblog.net/2007/06/29/getting-advanced-with-e4x/
Basically the guy who wrote this says: Use a namespace for your feed and then add the yweather to it. Once that's done we can use the feed as follows:
var condition = weatherFeed..yweather.condition.@text;
Good luck!
ruiganga
May 21st, 2009, 08:52 AM
HI
I've done it without the API. What I did was:
- Load the RSS
- since the RSS is almost the same, with regular changes, I am using subbstring to grab the values I need to make my app work
- I did a simple app that loads the temperature and the weather state to display the correpsondent image
And thats it, and it looks funny, see:
http://www.gohopa.com
I am thinking about what things people would like to have in their first homepage made in flash :)
StingRay5
May 21st, 2009, 09:14 AM
Hey!
That looks cool! So we both figured it out! Lol...
Offcourse there are tons of things you could integrate in such a page!
How about traffic information (if available), it's even possible to integrate a local version of Google Maps in Flash..
First thing I would integrate might be a little preloader, I took a little time to load the page, and it was all white, so people might think it's not working. And since it only takes 0.2 seconds for users to judge a page, it would be unfortunate if they would be gone before this cool page was loaded, right?
Cheers,
Do
ruiganga
May 21st, 2009, 09:20 AM
Hi
Thanks for the tip. I've not announce that domain yet. It is my break time project. There I want to put things I am learning since I am not a master in flash AS3.
I know a few things, and do a preloader is one of them. I'll do in the next version.
Another thing I am thinking is use SO so visitors can change there city and show the correspondent wether for today and 2 future days.
I also want to put a biorythm, but I did not figure the best design;
I am thinking also in offer a file delivery system, because sometimes people can't send some files using email. I think it will upload the file to the server, and the app will send a email with the download link for the file, in 48h the file will be erased. The only part is missing is a way to automatically delete the 48h files. What do you think about this service? Any idea? Thanks :)
StingRay5
May 23rd, 2009, 08:01 AM
That sounds really cool! Why would you use an SO if you could also use cookies that don't expire? If your primary goal is just to use Flash, I can see it, but otherwise, I think it's a lot easier using PHP for storing their preferences.
I think you should ask some bioanalyst about the biorythm thing, but it sounds cool. If your site would become a homepage for people, you could use PHP and MySQL to store their information, so you can register their log in times and such. Big brother is watching ;)
The file upload is a great idea! Too bad I didn't come up with it ;)
My guess is again, PHP and MySQL to keep the reference to the file. You should setup a script that compares the time of the download request and the time of upload. If it's bigger than 48 hours, it should deny access to the file and delete, if not, the download link will work.
And if you're really server savvy, you might even configure your server to check those times, without any user interaction. But I'm not so savvy either, so wouldn't be able to help you out with that one :p
cheers!
ruiganga
May 23rd, 2009, 01:50 PM
Hi
the file upload will be something much easier. I don't want to use much server, thats why i am avoiding PHP and mySQL, may be in the future. Now I am thinking about using only XML, PHP to create Folders and also to delete them. Each day the uploader will save the files in one folder, and after the 2 days the folder will be deleted with all files inside.
I am not sure how I'll be doing that, but I will :)
The biorythm i have already purchased from flashden. The only complication I have now i with the design. I want to make it look nice, not only copy and paste.
I'll use SO instead of cookies because normally user don't know how to erase them, and the browser does not have a button to erase it like have to cookies. As I searched, the SO will keep in the computer and always will work even if the uer didn't come up to the site.
Know I am searching about a code that allow user to rightclick the site (or something like that) and add it as homepage. Unitl now I don't know how to do, only that I'll need Javascript.
Any ideas?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.