Hi Brendan makes sense to put the code :-), With the format I was looking for following code works perfectly for me, I am not sure thats the right way of coding but this is working for my purpose. I am pretty sure there can be far far better way for this Anuj /**************************CODE******************/ <mx:Script> <![CDATA[ import mx.messaging.channels.StreamingAMFChannel; import mx.controls.Alert;
[Bindable] public var track:String; private function init():void { btn_genkey.addEventListener(MouseEvent.CLICK,key); } public function key(event:MouseEvent):void { var newLength:uint = 12; var userAlphabet:String = "BCDFGHJKLMNPQRSTVWXYZ"; var alphabet:Array=userAlphabet.split(""); var alphabetLength:int = alphabet.length; var randomLetters:String = ""; var _keyfirstpart:String; var _keysecondpart:String; var _keythirdpart:String; var _keyforthpart:String; var _concatenatedString:String; for (var i:uint = 0; i < newLength; i++) { randomLetters += alphabet[int(Math.floor(Math.random() * alphabetLength))]; } _keyfirstpart=randomLetters.slice(0,3); _keysecondpart=randomLetters.slice(3,6); _keythirdpart=randomLetters.slice(6,9); _keyforthpart=randomLetters.slice(9,12); _concatenatedString=_keyfirstpart+"-"+_keysecondpart+"-"+_keythirdpart+"-"+_keyforthpart; text_ii.text=_concatenatedString; } ]]> </mx:Script> <mx:TextInput id="text_ii" x="645" y="270" width="224"/> <mx:Button id="btn_genkey" x="513" y="270" label="Generate key" width="124" /> On Mon, Jan 5, 2009 at 5:39 PM, Brendan Meutzner <bmeutz...@gmail.com>wrote: > So what did you end up putting together? Should post the code here for > the next guy... > > > Brendan > > > > On Mon, Jan 5, 2009 at 5:41 PM, anuj sharma <anuj...@gmail.com> wrote: > >> Awesome guys your guidance help me in achieving this withing 30 >> minutes, it is working now >> Thanks for your help again >> Anuj >> >> On Mon, Jan 5, 2009 at 2:19 PM, anuj181 <anuj...@gmail.com> wrote: >> >>> Hi >>> I need to work on a piece of code in which whenever user clicks on the >>> button , the code should generate random 12 character key having all >>> caps and no vowels in the format of XXX-XXX-XXX-XXX. Can anybody guide >>> me in this direction. Is there any built in function for that or do I >>> have to use my own logic for random generation in this specific case. >>> Any help will be appreciated. >>> Thanks >>> Anuj >>> >>> >> > > > -- > Brendan Meutzner > http://www.meutzner.com/blog/ > >