Help in array

Hi, I want to work check before displaying any information on what it is to not repeated with supply

My code:
var sp:Array = new Array( ‘Ball’ , ‘Seq’ , ‘Circle’ , ‘Rec’);
btn.addEventListener(MouseEvent.CLICK, Press);
function Press (event:MouseEvent):void
{
txt_1.text = sp[Math.floor(Math.random() * sp.length)];
txt_2.text = sp[Math.floor(Math.random() * sp.length)];
txt_3.text = sp[Math.floor(Math.random() * sp.length)];
txt_4.text = sp[Math.floor(Math.random() * sp.length)];
txt_5.text = sp[Math.floor(Math.random() * sp.length)];
txt_6.text = sp[Math.floor(Math.random() * sp.length)];
}

I don’t want to be in the field for similar txt1 with txt2 and txt3 for example…

the problem is the txt6 Empty
http://www.gulfup.com/?grjnGk

and the code is not like I want

because the array Do not be repeated
only once

I do not mind to be repeated
like I want “a” in txt1 and txt3 but not in txt2
I want “b” in txt2 and txt4 but not in txt1

The code sample I gave you is to generate random set of letter. You can use same with your require number (here 6 letters) of length.
Use same code to generate random set of 6 letter or whatever text you need…

function randomizeArray(array:Array):Array
{
var newArray:Array = new Array();
while(array.length > 0)
{
newArray.push(array.splice(Math.floor(Math.random( )*array.length), 1));
}
return newArray;
}
var myArr:Array = new Array(‘a’, ‘b’, ‘c’,‘d’, ‘e’,‘f’);
//call function here
var newRandomArr = randomizeArray(mayArr);

Then update your textfields with values from this array.

Hope this helps…

but I want “a” in txt1 and txt3 but not in txt2
I want “b” in txt2 and txt4 but not in txt1
how?

You better decide first you need repeat values or not.
If you are fine with repeat values but you do not want it to be consecutive, then you can just check values for each consecutive field.
Say, while setting value for txt2, check whether earlier field (txt1) has same value, if it does then replace it with some new value.
Do the same for all fields.

Hope this helps…

yes I want to check values for each consecutive field…
can you just give me example for the code
and how it works?

I suggest you understand the logic first,
I do not have any sample created now but just a quick one is below

//generate random value
var newRandomValue = Math.round(Math.random()*6);
if($(’#txt1’).val() == newRandomValue)
{
//get another randomNumber
newRandomValue = Math.round(Math.random()*6);
$(’#txt2’).val(newRandomValue);
}
else
{
$(’#txt2’).val(newRandomValue)
}

Same way you can check for other textfield consecutively.
You can use while loop to check random values.
Also, you can use for each loop to check and assign value for each textfield.
Just google for for each to study some sample codes

Hope this helps…

thank you