# Random xml loading help needed

**URL:** https://forum.kirupa.com/t/random-xml-loading-help-needed/308248
**Category:** Uncategorized
**Created:** [April 20, 2010, 6:30am UTC](https://forum.kirupa.com/t/random-xml-loading-help-needed/308248 "2010-04-20T06:30:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![AKDS](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@AKDS](https://forum.kirupa.com/u/AKDS)
#### Post date: [April 20, 2010, 6:30am UTC](https://forum.kirupa.com/t/random-xml-loading-help-needed/308248/1 "2010-04-20T06:30:55Z")

</div>

this is my first post here, and I urgently need some help with my code.  
I’m trying to make an application in which every time you hover on an image (there is only one image on the stage) a new quote is loaded into a dynamic textfield from an xml file displayed over the image.  
I have so far managed to load a quote from the xml and it looks good,  
but I don’t know how to randomize the quote, now it only loads the first quote every time I hover on the image.  
Do I need to rethink the whole code, or just add to it?  
Thanks in advance!

Here’s the code:

stop ();  
var XMLFILEURL:String = “news.xml”;  
var spacing:Number = 2;  
var parent = new Object();  
parent.childNodes = new Array();  
parent.nodeName = “news”;  
parent.childNodes[0] = new Object();  
parent.childNodes[0].nodeName = “news”;  
parent.childNodes[0].childNodes = new Array();  
parent.childNodes[0].childNodes[0] = new Object();  
var htmlTXT:Array = new Array();  
var msgNr:Number = Math.round(Math.random()\*(this.firstChild.childNodes.length - 1));  
var currentNews:Number = 0;  
var t\_txt:String = “”;  
scope.\_alpha = 0;  
var news:XML = new XML();  
news.ignoreWhite = true;  
news.load(XMLFILEURL);  
\_root[\_root.pressedmci.text].yArea = \_root[\_root.pressedmci.text].originaly;  
\_root.ruta.\_visible = true;  
\_root.rubrik = “”;  
\_root.innehall = “”;  
\_root.boken.object.\_alpha = 0;  
\_root.choklad.object.\_alpha = 0;  
\_root.wwf\_panda.object.\_alpha = 0;  
choklad.onRollOver = function ()  
{  
\_root[\_root.aktuellmci.text].yArea = \_root[\_root.aktuellmci.text].originaly;  
\_root.aktuellmc = this.\_name;  
if (\_root.choklad.fram == true)  
{  
\_root.choklad.yArea = \_root.choklad.destination;  
} // end if  
if (\_root.choklad.fram == false)  
{  
\_root.choklad.yArea = \_root.choklad.originaly;  
} // end if  
\_root.ruta.\_visible = true;  
\_root.ruta.\_x = \_root.choklad.\_x;  
trace(“XML loaded!”);  
\_root.ruta.rubrik = “Mikropaus”;  
\_root.ruta.innehall = news.firstChild.firstChild.nodeValue;   
};  
choklad.onRollOut = function ()  
{  
\_root.ruta.\_visible = false;  
\_root.choklad.yArea = \_root.choklad.originaly;  
};
