Saturday, September 20, 2008

Playing with ASCII values in Actionscript 3 - Part 1
Agenda: Populate combo box with drive letters from A to Z.

 var i:int=0;
for(i=65; i<65+26; i++)
{   
atoz.addItem(String.fromCharCode(i)+":");
}
driveListCombo.dataProvider = atoz;


Done, my combo box is populated with drive letters from A to Z.
Now, to convert a character to its ASCII value use charCodeAt() function of String. You can use it like below:
var selectedDrive:String = "C";
//Now, to get ASCII value for "C"
selectedDrive.charCodeAt(0);


Will update once I get more clarity on performing ASCII operations.

Please provide your valuable comments.

6 comments :

  1. I can't believe this post made it to flex.org.

    ReplyDelete
  2. frost devil (koolp2ppirate@hotmail.com)Friday, August 14, 2009 11:37:00 AM

    hey dude...
    there are only 26 letters in total...
    but yu've included 65+26....
    actually including 65..the remaining is 25...
    so it'z ascii 65+25 ‼¿¿

    ReplyDelete
  3. @Frost Devil
    I have used less than for(i=65; i<65+26; i++) and not "less than equal to". So, it will leave last element.

    Hope it helps.

    --
    Chetan Sachdev

    ReplyDelete