# Help loading random news/quotes in flash

**URL:** <https://forum.kirupa.com/t/help-loading-random-news-quotes-in-flash/239677>\
**Category:** Uncategorized\
**Created:** [September 24, 2007, 7:47pm UTC](https://forum.kirupa.com/t/help-loading-random-news-quotes-in-flash/239677 "2007-09-24T19:47:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![soclueless](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@soclueless](https://forum.kirupa.com/u/soclueless)\
**Post date:** [September 24, 2007, 7:47pm UTC](https://forum.kirupa.com/t/help-loading-random-news-quotes-in-flash/239677/1 "2007-09-24T19:47:53Z")

</div>

hi, i’m new at trying to use arrays. i am trying to set up a randomly loading quote/news section, that pulls from an xml, but also checks to make sure it’s not reloading an already shown news item. basically i’m trying to set up an array for this check, but it doesn’t seem to be working, can anyone help me? here is the code:

var max\_news\_items = 50;  
temp\_i = [0];

contain\_i = function(input, arrayData){  
for (g=0; g\<arrayData.length; g++) {  
if (arrayData[g] == input) {  
return 1;  
}  
}  
return 0;

}

GetTitleText = function(news\_xml, entry\_index){  
var entries = news\_xml.firstChild.childNodes;  
var title\_element = entries[entry\_index].firstChild;  
return title\_element.firstChild.nodeValue;  
}  
GetBodyText = function(news\_xml, entry\_index){  
var entries = news\_xml.firstChild.childNodes;  
var body\_element = entries[entry\_index].firstChild.nextSibling;  
return body\_element.firstChild.nodeValue;  
}  
GetEntry = function(news\_xml, index){  
var entries = news\_xml.firstChild.childNodes;  
return entries[index];  
}  
GetNewsCount = function(news\_xml){  
var entries = news\_xml.firstChild.childNodes;  
return entries.length;  
}  
ShowNews = function(news\_xml){  
if (!news\_xml.firstChild.hasChildNodes()){  
content\_txt.text = “Error Loading Quotes.”;  
content\_txt.\_alpha =100;  
return (0);  
}  
var entries = news\_xml.firstChild.childNodes;  
content\_txt.text = “”;  
content\_txt.\_alpha = 0;  
var i= Math.floor(Math.random()\*entries.length);  
this.onEnterFrame = function(){  
if(contain\_i(i,temp\_i)!=0){  
i= Math.floor(Math.random()\*entries.length);  
}  
}

```
    var title = GetTitleText(news_xml, i);
    var body = GetBodyText(news_xml, i);
    content_txt.htmlText += "&lt;P ALIGN='RIGHT'&gt;"+ title;     
    
    this.onEnterFrame = function(){
    if (content_txt._alpha&lt;100){
        content_txt._alpha+=10;
        }
    }
    if(temp_i.length&lt;entries.length){
    temp_i.unshift(i);
    }
    else{
        temp_i.pop();
    } 

```

}

RefreshNews = function(news\_xml){  
content\_txt.htmlText = “”;  
news\_xml.load(xml\_file+"?"+new Date().getTime());  
}
