Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default How can I avoid NaN

    When my .swf loads the variables from the .txt file
    (days=2&hours=17&minutes=10&seconds=56), the swf file starts and shows seconds
    "56" for one second then says "NaN"...Any help is appreciated.
    Thanks,
    Trint

    trints Guest

  2. Similar Questions and Discussions

    1. Avoid coping homepage ??
      Hi al, What should i do so people cant copy or save my homepage? Regards Sasha
    2. How to avoid this
      Hi, I have a project where when the user scroll over the buttons a picture or movie display on the screen. All works fine, but moving between...
    3. Avoid SmartNavigation
      I've done some investigating about various problems with the SmartNavigation feature. It seems to me that the general consensus is to avoid...
    4. Avoid Insert
      I have an insert page and have written some javascript to validate the page. The validation works great but I need to stop the insert if the user...
    5. how to avoid authentication
      Hi All users should authenticate to reach some page. How to avoid this for some users. Thanks Konrad
  3. #2

    Default Re: How can I avoid NaN

    variables loaded from a text file are loaded as string variables. you'll need to convert them to numbers.
    kglad Guest

  4. #3

    Default Re: How can I avoid NaN

    kglad,
    I've been reading and can't get it right with number ()
    How would I do that here:
    stop();
    var dateVars = new LoadVars();
    dateVars.onLoad = function(ok) {
    if (ok) {
    clock.secondsleft = dateVars.seconds;
    clock.minutesleft = dateVars.minutes;
    clock.hoursleft = datevars.hours;
    clock.daysleft = dateVars.days;
    }
    };
    dateVars.load("countdown.txt");
    myinterval = setInterval(countDown, 1000);
    function countDown() {
    clock.secondsleft -= 1;
    if (clock.secondsleft<0) {
    clock.secondsleft += 60;
    clock.minutesleft -= 1;
    }
    if (clock.minutesleft<0) {
    clock.minutesleft += 60;
    clock.hoursleft -= 1;
    }
    if (clock.hoursleft<0) {
    clock.hoursleft += 24;
    clock.daysleft -= 1;
    }
    }
    Thanks,
    Trint

    trints Guest

  5. #4

    Default Re: How can I avoid NaN

    if number() won't work, use parseInt()
    dk_says_hey Guest

  6. #5

    Default Re: How can I avoid NaN

    Don't see you using Number anywhere in your code, so let me just add to the
    shots in the dark ;-)

    clock.secondsleft = Number(dateVars.seconds);
    clock.minutesleft = Number(dateVars.minutes);
    clock.hoursleft = Number(datevars.hours);
    clock.daysleft = Number(dateVars.days);

    John

    --
    ----------------------------------------------------------------------------
    -----------
    RESOURCES
    [url]http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash[/url]
    ----------------------------------------------------------------------------
    -----------
    TUTORIALS at
    [url]www.laiverd.com[/url]
    Flash & PHP Emailform
    Using textfiles in Flash
    ----------------------------------------------------------------------------
    -----------


    Laiverd.COM Guest

  7. #6

    Default Re: How can I avoid NaN

    i don't think there are any situations when parseInt() would work and number() or multiplying by 1 would fail. in addition, parseInt() is very different from number().
    kglad Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139