Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3: How to convert ascii code to character actionscript

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

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

What I want to create is a kind of convertor from canvas localX and localY to my new coordinates like A2.

I am thinking of implementing if condition this way

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

This way I can assigned needed coordinates in X range. e.g. 1, 2 ,3 etc

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

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

like image 860
Oleg Tarasenko Avatar asked Oct 01 '09 14:10

Oleg Tarasenko


1 Answers

The same way as in JavaScript: fromCharCode. If y is an integer starting at 1 for A:

String.fromCharCode(64+y)+x
like image 80
bobince Avatar answered Sep 28 '22 03:09

bobince