# Rss reader problem

**URL:** https://forum.kirupa.com/t/rss-reader-problem/263843
**Category:** flash
**Created:** [June 19, 2008, 5:20pm UTC](https://forum.kirupa.com/t/rss-reader-problem/263843 "2008-06-19T17:20:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![koolkrasher](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@koolkrasher](https://forum.kirupa.com/u/koolkrasher)
#### Post date: [June 19, 2008, 5:20pm UTC](https://forum.kirupa.com/t/rss-reader-problem/263843/1 "2008-06-19T17:20:34Z")

</div>

Hello all. I seem to be having a little problem with my rss reader. So far everything i needed it to do it does excpt 1 thing. i can not get the first item to deiplay by default.

heres my doce

```auto

//lb = list box component
//ta = text area component
 
var loader:URLLoader = new URLLoader();
loader.addEventListener (Event.COMPLETE, onLoaded);
 
lb.addEventListener (Event.CHANGE, itemChange);
 
function itemChange (e:Event):void
{
 ta_txt.htmlText = lb.selectedItem.data;
}
 
var xml:XML;
function onLoaded (e:Event):void
{
lb.selectedItem= 0;
lb.selectedIndex = 0;
ta_txt.htmlText = xml.item[lb.selectedIndex].description;
 xml = new XML(e.target.data);
 var il:XMLList = xml.item;
 for (var i:uint=0; i<il.length(); i++)
 {
  lb.addItem ({data:il.description.text()*,
  label:il.title.text()*});
 }
}
//trace(xml.item[lb.selectedIndex].description);
 
loader.load (new URLRequest("http://domain.net/screensaver/feed-alternate.xml"));
view_btn.addEventListener(MouseEvent.CLICK, viewOnline);
 
function viewOnline(event:MouseEvent):void
{
 navigateToURL(new URLRequest(xml.item[lb.selectedIndex].link));
}

```

any one have an idea of how i can accive this?

– just figured it out fix is in the edeit Thanks again guys

---

<div class="post-metadata">

### Author: ![skineh](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@skineh](https://forum.kirupa.com/u/skineh)
#### Post date: [June 19, 2008, 8:10pm UTC](https://forum.kirupa.com/t/rss-reader-problem/263843/2 "2008-06-19T20:10:19Z")

</div>

Here’s the first thing that I noticed.

```auto

ta_txt.htmlText = xml.item[lb.selectedIndex].description;
 xml = new XML(e.target.data);

```

You’re assigning the htmlText of your text field before you declared what “xml” is. I’m surprised it’s not throwing an error because of that. If it’s really that simple of a problem, then you should be able to just swap those two lines and have it working for you.

Also, I’d set the selectedItem/Index of your list box AFTER you’ve filled it with all of the items. So maybe move around the lines in your complete handler to this:

```auto

function onLoaded (e:Event):void
{
      xml = new XML(e.target.data);
      var il:XMLList = xml.item;

      for (var i:uint=0; i<il.length(); i++)
      {
            lb.addItem ({data:il.description.text()*, label:il.title.text()*});
      }
 
      lb.selectedItem= 0;
      lb.selectedIndex = 0;
      ta_txt.htmlText = xml.item[lb.selectedIndex].description;

}

```

Just a hunch after a quick glance. Hope it helps!

---

<div class="post-metadata">

### Author: ![koolkrasher](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@koolkrasher](https://forum.kirupa.com/u/koolkrasher)
#### Post date: [June 20, 2008, 4:04pm UTC](https://forum.kirupa.com/t/rss-reader-problem/263843/3 "2008-06-20T16:04:04Z")

</div>

Thanks for the help thats what i wound up doing. I took a breather and came back 5 mins later and i saw the answer clear as day. It was as simple as moving lines around just as you said.

Thanks again

---

<div class="post-metadata">

### Author: ![skineh](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@skineh](https://forum.kirupa.com/u/skineh)
#### Post date: [June 20, 2008, 5:13pm UTC](https://forum.kirupa.com/t/rss-reader-problem/263843/4 "2008-06-20T17:13:15Z")

</div>

Glad to hear it’s working for you. 🙂 Happy to help.
