Saturday, September 20, 2008
Playing with ASCII values in Actionscript 3 - Part 1
Agenda: Populate combo box with drive letters from A to Z.
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:
Will update once I get more clarity on performing ASCII operations.
Please provide your valuable comments.
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.
Subscribe to:
Post Comments
(
Atom
)
I can't believe this post made it to flex.org.
ReplyDeleteindeed.
ReplyDeleteAnd DZone.
ReplyDeletewhere's part 2?
ReplyDeletehey dude...
ReplyDeletethere 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 ‼¿¿
@Frost Devil
ReplyDeleteI 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