LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-07-2007, 08:33 PM
skitzer skitzer is offline
Registered User
 
Join Date: Oct 2006
Posts: 166
Rep Power: 7
skitzer is on a distinguished road
setinterval resetting before loop completes

I've got a timer set up using setInterval. The function clears the interval id, attempts to execute and then resets the interval. The problem is that it isn't executing all of the code before the timer is reset:

Code:
function readDB():Void
{ 
   clearInterval(intervalId)
   trace("--clearIntervalId")
   trace("polling db " + myArray.length)
 
   for (var i:Number = 0 ; i < myArray.length; i++)
   {
       var url:String = dbPath + "readData.asp"
 
       trace(i + " reading")
 
       var allData:LoadVars = new LoadVars()
       allData.myLetter = myArray[i].ID
       allData.sendAndLoad(url, allData, "POST") 
 
       allData.onLoad = function(success:Boolean)
       {
            trace("allData returned: " + success)
 
            if (success)
                trace("DB returns " + this['ID'])
 
        }
    }
 
   intervalId = setInterval(readDB, 1000)
   trace("--setIntervalId\n")
}
The output shows the intervalID is being set before the data is loaded from the database. What's the problem here? Here is some of the output from the trace statements...:

--clearIntervalID
polling db 4
0 reading
1 reading
2 reading
3 reading
--setIntervalId 1

allData returned: true
DB returns id1
allData returned: true
DB returns id2
allData returned: true
DB returns id3
allData returned: true
DB returns id4
--clearIntervalID
polling db id4
0 reading
1 reading
2 reading
3 reading
--setIntervalId 2

allData returned: true
DB returns id1
allData returned: true
DB returns id2
allData returned: true
DB returns id3
allData returned: true
DB returns id4
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I loop last 75% of swf a few times then loop the whole swf? mafadecay General Flash 0 05-24-2011 10:36 PM
video won't loop odaat Newbies 1 11-17-2007 08:33 PM
How to loop a movie clip? golferstud84 Flash MX 1 11-17-2005 04:30 AM
Resolved: sound loop button juury Newbies 2 03-08-2004 04:49 AM
Resolved: sound loop problems juury Flash MX 2 03-07-2004 08:13 AM




All times are GMT. The time now is 06:20 AM.