Skip to main content
Participating Frequently
February 5, 2007
Question

Subtracting 2 characters(Flash MX)

  • February 5, 2007
  • 1 reply
  • 272 views
Hi guys,
I am trying to subtract 2 characters in action script, My code line looks like this : temp=Number(str.charAt(j)-'A');
trace(temp);
But everytime i run the command i get NaN as the O/P, such a command works fine in C, what to do to get this working in actionscript?
This topic has been closed for replies.

1 reply

Inspiring
February 5, 2007
Hi,

What does such a thing yield in C?
Does it substract ASCII codes?
Then I would look into the charCodeAt() and fromCharCode() methods.

trace("C" - "A");
also gives NaN, so converting it to a Number doesn't do much better :)

HTH,
Manno

thunder_storm wrote:
> Hi guys,
> I am trying to subtract 2 characters in action script, My code line looks like
> this : temp=Number(str.charAt(j)-'A');
> trace(temp);
> But everytime i run the command i get NaN as the O/P, such a command works
> fine in C, what to do to get this working in actionscript?
>

--
----------
Manno Bult
http://www.aloft.nl
manno@xs4all.nl
Participating Frequently
February 5, 2007
Such a code in C wud yield the difference between the postition of the two chars in the string array.. eg. str='abcd..'
so b-c = 1 .. i m not checking this so i may be wrong but from past exp i think its what we get..
It does not subtract the ascii codes... i know abt the charCode() .. i wud like to know if there is a way i can get the difference in the position of the 2 chars..