AS2 Push appearing not to be working

baxters80
baxters80 used Ask the Experts™
on
I have three existing arrays Option1, option2, option3
I am first trying to push the current record including option1, option2, and option3 into an array answers2 and then I randomize them and output array1, array2, array 3
I am performing a push so that they populate
The code is attached.I just cannot get this to work...
random.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Engineering Manager / Architect
Commented:
Got a bit lost by your code so I did a small example of how to populate an array with data from another array and then randomizing it. Here's the code:

var array1:Array = [];
var options:Array = ["Value1", "Value2", "Value3", "Value4", "Value5"];

populateAndRandomize();

function populateAndRandomize():Void
{
	for(var i:Number = 0; i < options.length; i++)
	{
		array1.push(options[i]);
	}
	trace("Pre-randomize: " + array1);
	array1.sort(RANDOM_SORT);
	trace("Randomized: " + array1);
}

function RANDOM_SORT(a, b):Number
{
	return (Math.random() >= 0.5) ? 1 : -1;
}

Open in new window


Good luck!
-V

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial