Hi users of stack overflow I am currently struggling with randomizing my data via as3 and xml.
I can load in the xml fine and generate a random venue however when I click on the random button I have created, the same node is shown twice! Basically I just want to randomly select data with no repeat of the previous venue if this makes sense.
My xml:
<gallery>
<venue>
<name>1</name>
<description>1</description>
<picture>images/1.jpg</picture>
<thumb>thumbs/1.jpg</thumb>
<address>1</address>
<website>http://1.co.uk</website>
</venue>
<venue>
<name>2</name>
<description>2</description>
<picture>images/2.jpg</picture>
<thumb>thumbs/2.jpg</thumb>
<address>2</address>
<website>http://2.co.uk</website>
</venue>
<venue>
<name>3</name>
<description>3</description>
<picture>images/3.jpg</picture>
<thumb>thumbs/3.jpg</thumb>
<address>3</address>
<website>http://3.co.uk</website>
</venue>
</gallery>
My current code:
var xml:XML = <venues>
<venue name="" description="" address="" website="" picture=""/>
<venue name="" description="" address="" website="" picture=""/>
<venue name="" description="" address="" website="" picture=""/>
<venue name="" description="" address="" website="" picture=""/>
</venues>;
var Gallerylist:XMLList = new XMLList(xml.venue);
function RandomGallery(e:Event)
{
var rand:int = Gallerylist.length() * Math.random();
myTextBoxTitle.text = myXML.venue.name[rand]
myTextBoxDes.text = myXML.venue.description[rand]
myTextBoxAddress.text = myXML.venue.address[rand]
myTextBoxWeb.text = myXML.venue.website[rand]
myVenueImage.source = myXML.venue.picture[rand]
}
randomBTN.addEventListener(MouseEvent.MOUSE_DOWN, RandomGallery);