# XML random quote rotator help

**URL:** <https://forum.kirupa.com/t/xml-random-quote-rotator-help/320053>\
**Category:** flash\
**Created:** [March 12, 2011, 6:54pm UTC](https://forum.kirupa.com/t/xml-random-quote-rotator-help/320053 "2011-03-12T18:54:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mentru](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mentru](https://forum.kirupa.com/u/mentru)\
**Post date:** [March 12, 2011, 6:54pm UTC](https://forum.kirupa.com/t/xml-random-quote-rotator-help/320053/1 "2011-03-12T18:54:10Z")

</div>

Hi,

I’ve been messing around with this XML random quote rotators from this [site](http://flashadvanced.com/xml-random-quotes-rotator/) but I’m unable to make it so it doesn’t repeat the same quote twice. It has a tendency to show the same quote 3x in a row.

```php

//importing tween classes
import fl.transitions.Tween;
import fl.transitions.easing.*;

//we create a variable to store the loaded XML
var xml:XML;
//the path to the xml file
var xmlPath:String = "data/quotes.xml";
//we create a loader and when the loading is over we call the xmlComplete function
var loader:URLLoader = new URLLoader();
//a url request for our loader
var req:URLRequest = new URLRequest(xmlPath);
loader.addEventListener(Event.COMPLETE, xmlComplete);
loader.load(req);
//a variable for our tween
var myTween:Tween;
//we need to set a timer 
var timer:Timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, changeQuotes);
timer.start();

function xmlComplete(e:Event):void{
    xml = new XML(e.target.data);
    addQuotes();
    randomQuoteTween();
}

//we create arrays to store the quotes and the authors
var quotesArray:Array = new Array();
var authorsArray:Array = new Array();
//we need a random quote number 
var randomNumber:Number;

function addQuotes(){
    //we loop through the "quote" element of our XML 
    for each(var item:XML in xml.quotes.quote){
        //we fill the arrays with quotes and authors 
        quotesArray.push(item.content);
        authorsArray.push(item.author);
       
    }
}

function randomQuoteTween():void{
    //calculating the random number
    randomNumber = Math.round(Math.random() * (quotesArray.length - 1));
    //filling the text fields
    quoteMC.quoteTxt.text = quotesArray[randomNumber];
    authorMC.authorTxt.text = authorsArray[randomNumber];
    //creating tween effects
    myTween = new Tween(quoteMC, "alpha", Strong.easeOut, 0, 1, 3, true);
    myTween = new Tween(authorMC, "alpha", Strong.easeOut, 0, 1, 3, true);
}

function changeQuotes(e:TimerEvent){
    randomQuoteTween();
}

```

I figured it requires using shuffle, but I don’t know how to put it in this code. I’m fairly new at this and would appreciate any assistance.

Thanks
