8 Replies Latest reply on Jun 25, 2007 10:03 AM by Greg Dove

    setInterval Prob

    ewon15 Level 1
      I am using setInterval to call a function where the variables are being increased... after running through twice it stops and doesn't recognize the variables as being numbers... here is my code. I'm not sure i am explaining myself well, so let me know if it doesn't make sense. any advice is much appreciated!

        • 1. Re: setInterval Prob
          Greg Dove Level 4
          I haven't looked in depth at your code, but if it looks like it calls

          loadInfo(0,undefined) every 1 second.

          ctotal is not defined until the xml has loaded

          And *I think* (not 100% sure, I'll do quick test now) that these arguments in the setInterval call will be by value and not reference.... so they won't change from the first call. Please others correct me if I'm wrong on this.
          • 2. Re: setInterval Prob
            ewon15 Level 1
            huh... okay, so should i be calling the setInterval within the loadXML function where ctotal is being defined? and if the parameters are recognized as a set value rather than a reference to an every changing value, how should i deal with this? would updateAfterEvent do anything for me?
            • 3. setInterval Prob
              Greg Dove Level 4
              yes you should call setInterval from inside your loadXML function...updateAfterEvent is not relevant here. I'm just taking a look at the other part... I'm guessing its just best to access the current values from inside your loadInfo function. Will answer shortly
              • 4. Re: setInterval Prob
                SymTsb Level 2
                If your setInterval depends on the data from the xml file then you need to wait for it to load. Call the loadInfo from inside the loadXML function.
                • 5. Re: setInterval Prob
                  Greg Dove Level 4
                  I can't see you using the 'm' argument in any case..

                  So why not just change all the 't' to (ctotal-1) inside your loadInfo function.

                  and remove the aguments m and t from the function?

                  • 6. Re: setInterval Prob
                    Greg Dove Level 4
                    ps. a quick way to do that is:

                    function loadInfo(){
                    var t = (ctotal-1) ;

                    and leave the rest as it was
                    • 7. Re: setInterval Prob
                      ewon15 Level 1
                      okay, i was using the argument m, b/c when i left it with out m and just used p it wasn't incrementing for some reason...

                      okay, so now everything is set! thanks guys for helping me out... every thing worked out with taking away the arguments in the function and putting the setInterval within the XML loading function.

                      take it easy :0)
                      • 8. Re: setInterval Prob
                        Greg Dove Level 4
                        cheers... you're welcome.