String conversion

3 posts

Flag Post

Hi. I’m trying to figure out why I can’t take a string, string.fromcharcode(e.charcode), and put it into an array or something to hold that value. I tried putting it into a string, but then I can’t seem to look at that string later on when I trace it. I tried putting it into a textfield, but that give a similar problem.

 
Flag Post

Been a while since I did AS3, but if I recall, AS3 arrays are nice in that they have the push method:

var pressed:Array= new Array();
//In your event listener:
var pressedChar:String = String.fromCharCode(e.charcode);
pressed.push(pressedChar);

Then you can do whatever you want with that array.

If you’re still having issues, post the relevant code you have so far, and we can help you debug it.

Related docs:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html#push%28%29
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/String.html#fromCharCode%28%29

 
Flag Post

Post your code. You are probably doing something else wrong. Referencing the array in a local variable for example.