Random Text from XML File

I have been all over the Internet looking for a random text generator that used more than one variable. I do not have time to create it.

What I have is a series of old baseball newspaper headlines that I want to generate randomly as the visitor clicks through the website or automatically generate a new one at a given interval if they remain on the page for longer.

Ideally, I would like something that uses Flash 8 (AS2) and XML so that I only need to edit the XML file to add a new headline.

I have the Flash file I want to dump the data into set up like and old newspaper, so I need to place the headline in one place, with its own special type formatting, and the year in another, with its own formatting.

Any ideas?

Thanks in advance!

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you attach your XML file?
TammiColeAuthor Commented:
Sure! Thanks for the help! headlines.xml
Are you using AS2 or AS3?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

and do you want to load XML at runntime or embed to SWF?
TammiColeAuthor Commented:
AS2 and it needs to be editable in Flash 8. I am attaching what I have so far. It pulls in the headlines, but doesn't change...doesn't rotate. xmldata.fla xmldata.html
TammiColeAuthor Commented:
Which would cause less site-load lag?
TammiColeAuthor Commented:
Oh, it would also be nice if there was a button that would allow the user to flip through the headlines at their leisure...
You completed 95% :)

function loadXML(loaded) {
	if (loaded) {
		setInterval(loop, 1000, this.firstChild.childNodes);
		loop(this.firstChild.childNodes); //start now
	} else {
		content = "file not loaded!";

var lastIndex:Number;
function loop(nodes):Void{
	var index:Number = random(nodes.length);
	if(lastIndex == index){
	lastIndex = index;
	var node:XML = nodes[index];
	_root.myyear = getValue(node.childNodes[0].firstChild.nodeValue);
	_root.date = getValue(node.childNodes[1].firstChild.nodeValue);
	_root.headline = getValue(node.childNodes[2].firstChild.nodeValue);
	_root.subheadline = getValue(node.childNodes[3].firstChild.nodeValue);
	myyear_txt.text = _root.myyear;
	date_txt.text = _root.date;
	headline_txt.text = _root.headline;
	subheadline_txt.text = _root.subheadline;

function getValue(str:String):String{
	return str != undefined ? str : "";

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TammiColeAuthor Commented:
I guess I was further along than I thought :) Will it start over when the visitor goes to another page? Is there a way to make it totally random? Also, is there a way to add a button to stop the auto play so they can flip through it once by one? If we can't do both, I would really like it to be completely random first :)

Thanks again!
TammiColeAuthor Commented:
Thank you very much for your help!
Welcome and thanks for saving my time :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.