2 Replies Latest reply on Feb 16, 2007 6:55 PM by injpix

    Converting to number

      I'm trying to make a little typing app, which loads the exercises externally from text files.
      Here's what's in my text file:



      words being the amount of words in the exercise (12), and the rest being the words which should be typed.

      The Flash File (frame 1)

      var exerciseArray:Array = new Array();
      var exLoadVars = new LoadVars();
      exLoadVars.onLoad = startExercise;
      function startExercise(success) {
      if (success) {
      // load exercise
      var numberOfWords:Number = Number(exLoadVars.words);
      for (i=0; i<numberOfWords; i++) {
      } else {
      trace("loading failed");

      This should load my text file, and when I trace exLoadVars.words, it outputs '12' just like it's supposed to.
      However, if I convert this string to a number using var numberOfWords:Number = Number(exLoadVars.words);
      and then trace(numberOfWords); it outputs isNaN.
      (obviously, the trace("test") does not fire at all because numberOfWords is not a number)

      Why doesn't this work ??