[BNM] Converting string to variable name (Flash)
Sebastian von Bischopink
lists at allaboutseb.com
Mon Apr 10 12:12:50 BST 2006
Hi BNM,
another little Flash problem that i can't seem to solve.
Okay, in this example I have 3 variables (comment1..3). I randomly
generate a number between 1 and 3, and add it to the string
'comment'. So when i trace it i get 'comment1..3'. So far so good,
but when i assign this variable 'commenttext' to the textfield it
displays 'comment1..3' rather then the value of the variable 'comment1'.
So, i guess that i somehow have to "convert" the text string so it is
read as a variable name instead. Hope that makes sense ;)
Source code below:
comment1 = "1 - text for 1st comment.";
comment2 = "2 - text for 2nd comment.";
comment3 = "3 - text for 3rd comment.";
i = Math.floor(Math.random()*3+1);
commenttext = "comment" + i;
trace(commenttext);
_root.quote1.text = commenttext;
i greatly appreciate any help,
Seb
More information about the BNMList mailing list
BNMList is hosted by Screenlists, a Screen-Play.net service