A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] Possible to advance letters similarly to numbers?

  1. #1
    Senior Member Speed85's Avatar
    Join Date
    Apr 2007
    Posts
    292

    [F8] Possible to advance letters similarly to numbers?

    This is just a quick question, is it possible to advance letters similarly to numbers? Like if you have a variable holding a number you just need to type varName++ can you do the same thing with letters?

    I ask because I'm thinking about making a flash chess game and am thinking about how to go about it. I'm thinking the best way would name all the tiles according to their position (a1-a8, b1-b8, etc) then when a piece is clicked on it would check each tile along that piece's range and if it is open it would highlight that tile.

    Would it be practical to code it to pull the substring of whatever variable I am using to check the tiles and advance it accordingly. If that didn't make sence, something like this:

    code:

    tileToCheck = a2;
    //here would be some code to check that tile
    tileToCheck = tileToCheck.substring(1,1)++ + tileTocheck.substring(2,1);



    I probably dont have the syntax right, but regardless, would that be the best way? Should I store each part of the name separately? Or should I just store the letters as their numeric counterpart (a=1, b=1, etc).

    Thanks for any help/advice

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    If I understand your question, each letter has a unicode equivalent but it's clunky and causes some extra drag on the processor. The best way is to just make an array of the alphabet and look up their member values.

    abc = ['a','b','c',...'z'];

  3. #3
    Senior Member Speed85's Avatar
    Join Date
    Apr 2007
    Posts
    292
    cool, that works also

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center