# Removing Randomization from Array Creation

**URL:** <https://forum.kirupa.com/t/removing-randomization-from-array-creation/274678>\
**Category:** flash\
**Created:** [November 2, 2008, 8:35pm UTC](https://forum.kirupa.com/t/removing-randomization-from-array-creation/274678 "2008-11-02T20:35:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [November 2, 2008, 8:35pm UTC](https://forum.kirupa.com/t/removing-randomization-from-array-creation/274678/1 "2008-11-02T20:35:34Z")

</div>

The code below randomizes the order of some quiz answers, but I’ve decided that I need a version where the quiz answers are in a particular order.  
I thought it would be easy to turn off the randomization by using the value from

```auto
answers.child("*").length()

```

to feed the array counter. Instead, the script runs slow and kills. If I trace the value of  
answers.child("\*").length() I get a countdown: 4 3 2 1. Seems simple enough, but the compiler hates using those number as is.  
So I’m scratching my head - how should I simplify this array creation so that the answers are taken in order?

```auto

        public function shuffleAnswers(answers:XMLList) {
            var shuffledAnswers:Array = new Array;
            while (answers.child("*").length() > 0) {
                trace(answers.child("*").length()); // 4 3 2 1
                var r:int = Math.floor(Math.random() * answers.child("*").length());
                shuffledAnswers.push(answers.answer[r]);
                delete answers.answer[r];
            }
            return shuffledAnswers;
        }

```
