Unique Random Generator

The following code generates the unique random numbers.
User will input max length (for ex: 10 unique random numbers from 0 to 10) in textinput , and on keyup event values are populated in text area one below another.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”vertical” width=”100%” height=”100%”
backgroundAlpha=”1″ backgroundGradientAlphas=”[1,1]” backgroundGradientColors=”[#999999,#999999]”>
import mx.utils.ObjectUtil;
private function calUniqueRandomNo(maxCount:Number):void
resText.text = “”;
var resArr:Array = new Array();

var randNo:int = parseInt((Math.random()*maxCount).toString()) ;

resText.text += resArr.toString();

private function search(valueToSearch:int,arrayToSearch:Array):Boolean
for(var j:int=0;j<arrayToSearch.length;j++)
if(arrayToSearch[j]== valueToSearch)
return true;
return false;
<mx:FormItem label=”Count:”>

<mx:TextInput id=”maxCountIp” keyUp=”{calUniqueRandomNo(Number(maxCountIp.text))}” />

<mx:TextArea id=”resText” width=”70″ height=”70%”/>

If any other way , welcome to post as comment.


  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: