PDA

View Full Version : Convert definition of a variable in text file into a numeric value?


confused1
09-18-2003, 03:10 PM
I have a variable in a text file for a total of announcements. It reads:
"&totalAnnounce = 3". In my flash movie, I have a frame that says:

totalAnnounce = Number(totalAnnounce)
count = count + 1

thinking that the first line would convert the definition of 'totalAnnounce' into a numeric value. In a following frame, I have the code:

count = count + 1
if (totalAnnounce > count) {
gotoAndPlay("announce3");
} else {
gotoAndPlay(1);

so that the movie keeps going to the next section until the # of announcements ='s the count number. If I put:

totalAnnounce = 5 (or some number)

it works fine. But how do I get my code to read the value of the number that someone has entered in the text file? Thank you for the help!

webguy
09-18-2003, 06:49 PM
I see nothing wrong with your conversion code, just make sure you are properly getting the number. Here is a little Number conversion test I ran.


n = "1"; // making n = a string value of "1"

trace(n+" = n as a string"); // traces 1

trace(n+1+" = trying to add one to the string"); // traces 11

n = Number(n);

trace(n+" = n as a permanent number"); // traces 1

trace(n+1+" = adding 1 to n now that it is a number"); // traces 2


web