Skip navigation
pbesong
Currently Being Moderated

setInterval problem

Mar 18, 2007 7:02 PM

I have names in some text files split up alphabetically by every 3 letters (abc, def, ghi, etc.). I'm using a slider to navigate between the different files. When it loads in initially via frame script it works fine. Here is my code:


loadVariablesNum("print/pm0000abcNames.txt",0);

function checkParamsLoaded() {
if (name1 == "test name") {
trace("not yet.");
} else {
trace("finished loading. killing interval.");
trace("-------------");

clearInterval(param_interval);

for (i=1; i<=NumNames;i++) { // Text file sample entry below:
names = eval("name"+i); // &name1=Abbot, Joseph
nameID
= eval("nameID"+i); // &nameID1=295
BioExists = eval("BioExists"+i); // &BioExists1=0
} // &NumNames=52

slot1_name = names[1]; // display each name in one of the 7 slots
slot2_name = names[2];
slot3_name = names[3];
slot4_name = names[4];
slot5_name = names[5];
slot6_name = names[6];
slot7_name = names[7];
link1 = nameID[1]; // set the nameID key for each so we know whose bio to feature if selected
link2 = nameID[2];
link3 = nameID[3];
link4 = nameID[4];
link5 = nameID[5];
link6 = nameID[6];
link7 = nameID[7];

}
}
var param_interval:Number = setInterval(checkParamsLoaded, 1000);


This works fine. The problem comes when I try to load the def, ghi, jkl, or some other text file that I call from a slider control movie clip. The new data loads, but every second it keeps reloading. Makes it impossible to sroll thru the displayed names. Here is my call to this function from the slider movie clip:


loadVariablesNum("print/pm0000"+letterRange+"Names.txt",0);
_root.checkParamsLoaded();

setInterval(_root.checkParamsLoaded, 1000);


It seems to keep reloading the names every second. When I change the setInterval number to 10000, it reloads the data every 10 seconds. It doesn't seem to be clearing the interval and just keeps reloading all the time. Is how I'm stating the setInterval from the slider movie clip wrong?

 
Replies
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 18, 2007 7:54 PM   in reply to pbesong
    where are you assigning name1="test name" before executing your setInterval()?

    p.s. there are easier ways to do this. you might check the loadvars() class and its onLoad handler.
     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 19, 2007 7:29 AM   in reply to pbesong
    you have to re-assign name1="test name" everytime you execute your setInterval().
     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 19, 2007 1:53 PM   in reply to pbesong
    you're welcome.
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points