Be a Supporter!

As3 Displaying Rss Weather Feed.

  • 265 Views
  • 2 Replies
New Topic Respond to this Topic
RadRacer
RadRacer
  • Member since: Oct. 17, 2005
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
As3 Displaying Rss Weather Feed. Aug. 6th, 2009 @ 05:23 PM Reply

Hello, I am trying to create my own weather program using yahoo's weather RSS feed. I've been following the tutorial on this site and everything is working as it should.

The thing is I want to break out the different elements . . . for example I don't want it to read 'full weather forcast provided by yahoo' at the end and I want the following days weather to be displayed in seperate textAreas. I'm new to AS3 and the code isn't really making sense to me, I was wondering if someone could help tell me how I could do this.

Here is Yahoos Astro Library . . . any help is really appreciated.

Here is the code:

var location_id:String='CAXX0246';
var grades:String='c';
var url:String='http://weather.yahooapis.com /forecastrss?p='+location_id+'&u='+grade s;
var richiesta:URLRequest=new URLRequest();
var loader:URLLoader;

richiesta.url=url;
richiesta.method=URLRequestMethod.GET;
loader=new URLLoader();
addListeners(loader);
try
{
loader.load(richiesta);
}
catch (error:Error)
{
trace('Unable to load requested document.');
}

function addListeners(d:IEventDispatcher):void
{
d.addEventListener(Event.COMPLETE,comple tato);
}

function completato(evt:Event):void
{
var vars:URLVariables=new URLVariables(evt.target.data);
var r:XML=new XML(evt.target.data);
var myXML:XMLDocument=new XMLDocument();
myXML.ignoreWhite=true;
myXML.parseXML(r.toXMLString());
var node:XMLNode=myXML.firstChild.firstChild ;
title_txt.text=node.firstChild.firstChil d.nodeValue;
var n:int=int(node.childNodes.length);
for(var i:int=0;i < n;i++)
{
if(node.childNodes[i].nodeName=='item')
{
var s:int=int(node.childNodes[i].childNodes.
length);
for(var j:int=0;j < s;j++)
{
if(node.childNodes[i].childNodes[j].node Name=='description')
info_ta.htmlText=node.childNodes[i].chil dNodes[j].firstChild.nodeValue;
}
}
}
}

I was going to post the file so anyone could just edit it directly but for some reason putfile.com now redirects me to ebaumsworld . . . first he steals other peoples contents now popular url's. jeesh.

RadRacer
RadRacer
  • Member since: Oct. 17, 2005
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to As3 Displaying Rss Weather Feed. Aug. 6th, 2009 @ 06:03 PM Reply

Looking at the code longer I can see that this is the important part right here:

for(var i:int=0;i < n;i++)
{
if(node.childNodes[i].nodeName=='item')
{
var s:int=int(node.childNodes[i].childNodes.
length);
for(var j:int=0;j < s;j++)
{
if(node.childNodes[i].childNodes[j].node Name=='description')
info_ta.htmlText=node.childNodes[i].chil dNodes[j].firstChild.nodeValue;
}
}

Basically what I guess I am asking is how do i tell it to display a 'childnode' into a different textArea? I don't want everything to appear in the same textArea box, I want them in different ones so I can rearrange, reformat, and resize at will. Does that make sense?

RadRacer
RadRacer
  • Member since: Oct. 17, 2005
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to As3 Displaying Rss Weather Feed. Aug. 7th, 2009 @ 10:52 AM Reply

Anyone? Does it not make sense or something? Tell me what your confused about if thats the case.