# Random values issue

**URL:** <https://forum.kirupa.com/t/random-values-issue/272555>\
**Category:** flash\
**Created:** [October 6, 2008, 2:42pm UTC](https://forum.kirupa.com/t/random-values-issue/272555 "2008-10-06T14:42:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![timdenty](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@timdenty](https://forum.kirupa.com/u/timdenty)\
**Post date:** [October 6, 2008, 2:42pm UTC](https://forum.kirupa.com/t/random-values-issue/272555/1 "2008-10-06T14:42:07Z")

</div>

Hi - I’m pulling simple xml text data into my flash movie, and am trying to pick a random xml node to display each time the movie plays. The code I’m using is below…

function loadXML(loaded) {

if (loaded) {  
xmlNode = this.firstChild;  
titledata = [];  
clientdata = [];  
textdata = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
titledata\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
clientdata\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
textdata\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
}  
firstItem();  
} else {  
content = “file not loaded!”;  
}  
}

xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“data.xml”);

p = random (i);

function firstItem() {  
textclip.title\_txt.text = titledata[p];  
textclip.client\_txt.text = clientdata[p];  
textclip.text\_txt.text = textdata[p];  
}

So ‘i’ is the total number of nodes, and ‘p’ is the currently displayed node, strangely ‘p = random (i)’ just won’t work for me.

What am i missing?

Thx
