Initialize the array like
var randomNumber:Array = ;
remove the math.floor function from your randomRange() function.
Hope this helps.
Hi, thanks for the help.....that seems to be working.......
however what to do to print the whole array?????
You can use Alert.show() or trace() to show the array values.
Use for loop if required.
well i'm doing this is flex.....and flex doesn't have trace().
I'm trying to randomize the index number while calling nodes from a XML file, that is the reason, i'm trying to put in a random number generator...cause number of nodes in XML are fixed. So with a random and unique number, i can call, say, 6 nodes from the XML without repeating them.
so, i wanted to check the if the random function repeats vaules? thus want to print the values......
this is getting confusing.......thanks for the help...however can you give something simple......so that it can help with my next goal of using the value in place of Index .....?????
There is a trace() method in Flex.
Math.rand() will eventually repeat. Any random number generator will.
That's the point of being random, it can be any value, even one you've seen
If you want to guarantee non-repeating numbers, you need to pull numbers out
of a sequence randomly and deal with collisions.
I have tried it again, though didn't get the result from the trace();. Am i using it correctly here???????
I have this function which checks for the uniqueness of the element in the array, if they are not unique, it pops the element. I wanted to check if it is behaving the way i'm expecting it to be.....however i don't know if i'm using the trace option at the right place or why is it not showing the values??????
private function Init(event:MouseEvent):void
var RandomArray:Array = ;
var i:int = 0;
for( var i:int = 0; i< 6; i++)
RandomArray[i] = randomRange(0, 6);
if(RandomArray.length > 1)
for( var a:int = 0; a<RandomArray.length; a++)
for(var b:int = a+1; b< RandomArray.length; b++)
Trace outputs to the debug console. It is not related to mx.logging.*
package which you can use if you want more control over the output.