First of all, let me explain that I am a designer and tend to struggle with code. However, I've been making a serious effort to learn AS3 and have had some unexpected success...until I hit this snag.

I have used the code below to create an RSS reader which works almost exactly as I'd hoped. I can load and parse the feed, pass the data to an object, and assign the various node data to dynamic elements on the stage (For the sake of simplicity, I've only included 2 items here, Item Title (title_txt) and Feed Title(feed_txt). I have also created 2 buttons (Prev Item, Next Item) to advanced through the Item tags in the XML and update the stage accordingly. All of this works perfectly.

Where I ran into trouble is when I try to add the ability to advance through multiple RSS feeds, update the data in my XML object, and update the elements on the stage. As you can see from my code, I have created a button called "Next Feed" that I am using to advance through the elements of an array (rssArray) which contains all of the RSS feeds.

As the code reads currently, (I've commented out the code that creates and calls the function to load the new feed) the "Next Feed" button correctly advances to the next feed and updates the appropriate variables. (the "trace" confirms this) However when I un-comment the "update feed" function and call it, all hell breaks loose.

I'm pretty sure that I've created some sort of unintentional loop where the function keeps loading itself into itself because the first time that the function is called, it is called 1 time (and the stage updates the way that I would expect). But each successive time that I click the "next feed" button, the "updateItem" function is called an additional time. (ie, the funtion is called 2 times, then 3 times, then 4 times, etc.)

I guess when I'm trying to do is to replace the old data in the xmlLoader object with the new data from the next feed in the array. I feel like I'm either really close or approaching this from a completely wrong direction. I've tried everything that I thought "should" work and I am now out of ideas. Hence, I decided to come here in the hope that a set of fresh eyes might be able see what I am missing.

I apologize for rambling but I hope that I've been clear. If I've haven't, please ask me and I'll try to clarify.

Thank you for taking the time to look at this, and I'd be very appreciative for any help that you can provide.

Greg

Code:
// DEFINES LIST OF AVAILABLE RSS FEEDS //
var rssArray:Array = new Array();
rssArray.push("feed_one.xml");// FEED 1
rssArray.push("feed_two.xml");// FEED 2
rssArray.push("feed_three.xml");// FEED 3
var arrayIndex:Number = 0;
var itemNum:Number = 0;

// LOADS & PARSES AN XML/RSS FILE //
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
trace("RSS Loaded");

// LOADS XML DATA AND PASSES IT TO OBJECTS ON THE STAGE //
function LoadXML(event:Event):void {
	try {
		var xmlData:XML = new XML(event.target.data);
		var rssList:XMLList = xmlData.channel.item;
		// DISPLAYS THE FEED DESCRIPTION AND TITLE //
		updateItem();

	} catch (e:TypeError) {
		//CREATES AND DISPLAYS ERROR GRAPHIC IF XML CANNOT BE PARSED//
		var redX:errorGraphic = new errorGraphic();
		redX.x = (stage.stageWidth / 2);
		redX.y = (stage.stageHeight / 2);
		this.addChild(redX);
		trace("Could not parse the XML");
		trace(e.message);
	}

	// CREATES FUNCTION FOR "NEXT" BUTTON //
	btn_next.addEventListener(MouseEvent.CLICK, nextItem);
	function nextItem(event:MouseEvent):void {
		if (itemNum == rssList.length() - 1) {
			itemNum = 0;
		} else {
			itemNum++;
		}
		updateItem();
		trace(arrayIndex + "--" + itemNum);
	}
	// CREATES FUNCTION FOR "PREVIOUS" BUTTON //
	btn_prev.addEventListener(MouseEvent.CLICK, prevItem);

	function prevItem(event:MouseEvent):void {
		if (itemNum != 0) {
			itemNum--;
		} else {
			itemNum = (rssList.length() - 1);
		}
		updateItem();
		trace(arrayIndex + "--" + itemNum);
	}
	// CREATES FUNCTION FOR "NEXT FEED" BUTTON //
	btn_nextfeed.addEventListener(MouseEvent.CLICK, nextFeed);

	function nextFeed(event:MouseEvent):void {
		if (arrayIndex == rssArray.length - 1) {
			arrayIndex = 0;
		} else {
			arrayIndex++;
		}
		itemNum = 0;
		//updateFeed();
		updateItem();
		trace(rssArray[arrayIndex] + "--" + itemNum);
	}
	
	// CREATES FUNTION THAT LOADS THE NEXT FEED IN THE ARRAY //
	//function updateFeed():void {
		//xmlLoader.load(new URLRequest(rssArray[arrayIndex]));
	//}
	
	// CREATES FUNTION THAT UPDATES THE ITEM DATA THAT IS DISPLAYED //
	function updateItem():void {
		title_txt.text = rssList.title[itemNum];
		feed_txt.text = xmlData.channel.description;
	}
}
xmlLoader.load(new URLRequest(rssArray[arrayIndex]));