|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how do I unconcatenate a string
ok so I've got a script
Code:
desc1 = "ring";
desc2 = "necklace";
desc3 = "earring";
growth = 0;
function make_txt() {
this.createTextField("desc_txt"+growth,growth,0,0,100,100);
nameology = "desc" + growth;
this["desc_txt"+growth].text = nameology;
growth++;
}
for (i=1; i<=3; i++) {
make_txt();
}
this Creates a text field, gives it a name, and gives it content. the for loop does it 3 times, so in there are 5 textfields... the variable "Growth" keeps adding one so the textfield names are "desc_txt1", "desc_txt2", "desc_txt3" Ok so most of that works... MY problem is getting the variable "Nameology" to be equal to a variable name, not a string. if I use Code:
nameology = desc + growth; it doesnt work because DESC doesnt have a value... if I give it one its either numeric or a string (or boolean or...) and if I keep it the way it is, the value of nameology is "Desc1", "Desc2" etc... I figured this is because Code:
nameology = "desc" + growth; creates a string. which is no good. Unless I can convert this string (which I dont know if is possible) to be read as a variable (the same variables that are at the top of the code (desc1 = "ring"; ... desc2 = "necklace"; ) ) have I confused everybody? Thanks in advance... |
|
#2
|
|||
|
|||
|
Hi, have you tried eval?
nameology = eval("desc" + growth); Lemme know how that goes, I'll test it out later if that doesnt work. |
|
#3
|
|||
|
|||
|
Sweeet jummping jesus on a pogo stick
it works! THanks ever so much |
|
#4
|
|||
|
|||
|
hehe yer I had loads of trouble on similar things till I found that. It works for movie names as well i.e.
eval("mymovie" + i)._x = 10; Doesnt work all the time though, Macromedia have a technote or two on the subject. Glad to have helped :¬) |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > how do I unconcatenate a string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|