# Translating letters too numbers

**URL:** <https://forum.kirupa.com/t/translating-letters-too-numbers/62355>\
**Category:** Uncategorized\
**Created:** [August 27, 2004, 3:46am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355 "2004-08-27T03:46:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdjstudios](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mdjstudios](https://forum.kirupa.com/u/mdjstudios)\
**Post date:** [August 27, 2004, 3:46am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/1 "2004-08-27T03:46:27Z")

</div>

i want to know if there is a way to translate letters to numbers look at the example.

a = 6  
b = 11  
c = 2

abc translated would be…  
6112

but i wouldnt know how to make the AS convert the 6112 to make ABC…  
any suggestions?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 3:53am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/2 "2004-08-27T03:53:53Z")

</div>

yes, but it can be a function a clipevent or is this executed from a button, that’s important.

if you tell me what exactly do u wanna achive, and why you wanna translate the numbers to letter and vice versa. maybe i can give you another solution!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 3:55am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/3 "2004-08-27T03:55:44Z")

</div>

huh? i dont understand it. i want to achieve a program for secret spies 🙂 … LOL. or if i can do it by numbers than maybe by lettters?  
a = k  
b = o  
c = z

koz = abc

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 3:56am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/4 "2004-08-27T03:56:59Z")

</div>

can you give me some examples of AS to make all “a’s” in a text the letter k?  
like if  
txt.letterA = R [translate  
txt.LetterR = A [re-translate

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 4:31am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/5 "2004-08-27T04:31:49Z")

</div>

oh by a BUTTON

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 10:56am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/6 "2004-08-27T10:56:27Z")

</div>

```auto

a = 3; \\ here you enter your values
b = 4;
c = 5;
 \\ shoul have a button named "submit" and a input text field with var name "inputed"
 _root.submit.onPress = function () {
	 lowered = inputed.toLowerCase();
	 resultcode = "";
	 for (i=0; i < inputed.length;i++) {
		 resultcode += eval (lowered.charAt(i));
		 }
		 result.text = resultcode;
	 }
 

```

Enjoy 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 12:36pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/7 "2004-08-27T12:36:41Z")

</div>

hmm i dont fully understand the concept. what do i put in result code? and im guessing i should have a txt box named resultcode?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 12:37pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/8 "2004-08-27T12:37:40Z")

</div>

I don’t think so. Since there are 26 letters in the alphabet, you’ll have number equivanlents that have more than 2 figures, so you need to put some sort of separator between the letters:

```auto
a = 3; \\ here you enter your values
b = 4;
c = 5;
 \\ shoul have a button named "submit" and a input text field with var name "inputed"
 _root.submit.onPress = function () {
	 lowered = inputed.toLowerCase();
	 resultcode = "";
	 for (i=0; i < inputed.length;i++) {
		 resultcode += eval (lowered.charAt(i)) + "_";
		 }
		 result.text = resultcode;
	 }
}

```

That way you can split the resulting string using the separator “\_” and retrieve the original words very easily.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 1:40pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/9 "2004-08-27T13:40:50Z")

</div>

for result.text = resultcode;  
I used a dynamic text box named result. Resultcode was a variable set to “” empty… each time you submit another string to it, otherwise it would have attached the result at the end each time it ran, creating a longer and longer string.  
And as Ilyas said you may be needing some kind of separator if you use numbers.  
Or use other letters instead, as in - reorder the alphabet.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 10:03pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/10 "2004-08-27T22:03:54Z")

</div>

alright i think i got it from here guys… thanks for your help!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 10:13pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/11 "2004-08-27T22:13:45Z")

</div>

oh wait, it works perfectly when i do this,

a="elp"  
b="dra"  
c=“lar”

and etc. but when i translate it back it will make it one long word with no spaces, so if i put a space into the inputted box and translate to result there will be no spaces. how would i make it so that the spaces in the input will be recorded into the result box.?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 10:38pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/12 "2004-08-27T22:38:09Z")

</div>

and how would i translate the code? i have,

```auto
elp="a"
dra="b"
lar="c"
pro="d"
der="e"
got="f"
hay="g"
far="h"
son="i"
red="j"
med="k"
yet="l"
hit="m"
rip="n"
jan="o"
gop="p"
wop="q"
win="r"
med="s"
met="t"
car="u"
rea="v"
dre="w"
ber="x"
vab="y"
xac="z"
 //should have a button named "submit" and a input text field with var name "inputed"
 _root.submit.onPress = function () {
	 lowered = inputed.toLowerCase();
	 resultcode = "";
	 for (i=0; i < inputed.length;i++) {
		 resultcode += eval (lowered.charAt(i));
		 }
		 result.text = resultcode;
	 }

```

but that doesnt seem to work. aand i cant put quotes around the dre or ber because it detects an error…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 10:45pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/13 "2004-08-27T22:45:55Z")

</div>

well when i try to translate elp, i get the translation of E.L.P instaed of the word. i would get deryetgop for elp. how do imake it so when i type in elp, i get A? or maybe would it be more logical to make the a = elp. instead of a=elp?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2004, 11:38am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/14 "2004-08-28T11:38:27Z")

</div>

> more logical to make the a = elp. instead of a=elp?

Huh :)???  
charAt(i) returns only one character.  
you should use substr instead.  
If nobody replyes … later when I have time I will write something.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2004, 3:53pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/15 "2004-08-28T15:53:15Z")

</div>

i cant use 3 letters? i really want to use more than 3 letters. i can translate all the a, b, c into the 3 lette rwords but i cant change them back…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2004, 4:52pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/16 "2004-08-28T16:52:52Z")

</div>

and theres another problem, not as big but when i translate it makes strange numbers that replace the letter heres a .swf to test it out

[http://mdjstudios.freeunixhost.com/secretcode.html](http://mdjstudios.freeunixhost.com/secretcode.html)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2004, 11:10pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/17 "2004-08-28T23:10:52Z")

</div>

ok dokey…  
this will make your button translate first, then decrypt on pressing it again via the variable _from1to3_. if you want separate buttons extract the code from the if/else statement 😉

```auto
der="e"
got="f"
hay="g"
e = "der"
f = "got"
g = "hay"
 \\ shoul have a button named "submit" and a input text field with var name "inputed"
 _root.submit.onPress = function () {
    if(from1to3 == 1){
	 lowered = inputed.toLowerCase()
	 resultcode = ""
	 for (i=0; i < inputed.length;i+=3) {
		resultcode += eval (lowered.substring(i,i+3)) //wer 3 is the length of your replacement code words
	}
        from1to3 = 0
	result.text = resultcode
	}
    }
    else{
	lowered = inputed.toLowerCase()
	resultcode = ""
	for (i=0; i < inputed.length;i++) {
		resultcode += eval (lowered.charAt(i))
	}
	result.text = resultcode
}

```

note i put the decryption script in first and the encryption script in the else statement…

Prophet.

EDIT:- on your .swf all i can find is that when you type “/” (without quotes) you get _\_level0_ come up… easily remedied by putting in a code encryption equivalent (or whatever you want to call it) for the / character… also, you might want to add one in for space as well otherwise if you code it and then decode it it will all be one huge word…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2004, 11:12pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/18 "2004-08-28T23:12:03Z")

</div>

I’m really not very skilled with flash actionscript, usualy write scripts with the AS dictionary near close :). And now again I’m at home and don’t have the flash installed.  
but let’s try something  
You can use 3 letters but you’ll have to use substr instead of charAt.

```auto
_root.submit.onPress = function () {
	 lowered = inputed.toLowerCase();
	 resultcode = "";
	 for (i=0; i < inputed.length;i+=3) {
		 resultcode += eval (lowered.substr(i,3));//will extract 3 characters beggining with the "i"th one
		 }
		 result.text = resultcode;
	 }

```

You’ll have problems with spaces though.  
Later Edit: See if it works … hope i Solved the spaces problem.

```auto
_root.submit.onPress = function () {
	 lowered = inputed.toLowerCase();
	 resultcode = "";
	 for (i=0; i < inputed.length;i+=3) {
		while (lowered.charAt(i)==" "){
                             i++;
                             resultcode += " "; \	he space isn't translated
                              }
                        resultcode += eval (lowered.substr(i,3));//will extract 3 characters beggining with the "i"th one and evaluate them as variables name.
		 }
		 result.text = resultcode;
	 }

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2004, 11:20pm UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/19 "2004-08-28T23:20:38Z")

</div>

lol looks like i just beat u to it 😉

just thought though, you cant name a variable a space… lol hope u did solve the space problem! 😉

Prophet.

EDIT:- that should work fine… although you should use an IF statement instead… otherwise you will get a loop error as the while loop will loop all the time its condition is true…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2004, 12:52am UTC](https://forum.kirupa.com/t/translating-letters-too-numbers/62355/20 "2004-08-29T00:52:36Z")

</div>

i really dont understand what you guys are saying so im going to post the .fla. im just really confused at the moment…

the fla is in the zip…

[Next page](https://forum.kirupa.com/t/translating-letters-too-numbers/62355.md?page=2)
