AS3: How to convert ascii code to ActionScript character

I want to create a board class from the canvas, which will allow you to track the position of a click on it in such coordinates as A2, where A ... D is the Y coordinate on a certain scale and 1 ... 3 is the X coordinate

For example, see the image http://img.skitch.com/20091001-k6ybfehid6y8irad36tbsiif15.jpg

What I want to create is a kind of converter from canvas localX and localY to my new coordinates, such as A2.

I am thinking about using this condition

if   (0.4 - x*size(from 1-3 here)/canvas.width <= X <= 0.4 + x*size(from 1-3 here)/canvas.width)
       X = x;

That way, I can assign the necessary coordinates in the X range. For example 1, 2, 3, etc.

But what to do with the alphanumeric range. (if, for example, I want to make it extensible) ...

Maybe there is a way to convert ASCII to char? Pls. offer your solution

+5
source share
2 answers

Just like in JavaScript: fromCharCode . If yis an integer starting with 1for A:

String.fromCharCode(64+y)+x
+16
source

you can use the fromCharCode function in the String class to do this.

for example: String.fromCharCode (ascii code);

0
source

All Articles