PDA

View Full Version : Easy Set-Interval Problem


ctarantino
01-10-2006, 04:41 PM
Hey Everyone,

This is probably going to be a very easy fix, but im not sure why its not working. Here's what i am trying to do, i have a main Movie, that loads SWF files one by one, and intervals by itself, i used to have the file reset after 30 seconds using the setInterval function, but now i want to put a script on the last frame of the individually loaded movies that tells the main timeline to reset the function, thus causing the interval to occur over and over, just independent of time.

Here is my main function:

//List of SWF's to be loaded//

var movies:Array = new Array ("1.swf","2.swf","3.swf");

//variables used for incrementing//
var index:Number = -1;

//incrementing function for individual SWF's//
function swf(){
index++;
if (index>=movies.length){
index=0;
}
loadMovieNum(movies[index],1);
fscommand ("fullscreen",true);
fscommand ("allowscale",true);
}


swf();

function reset(){
setInterval(swf,0000);
}

Here is the script i put on the last frame of my individual test movie:

function changer(){
_root.reset();
}

changer();

Thanks in Advance for any help you all provide,

Chris

mcmcom
01-10-2006, 08:46 PM
if i understand you correctly, the child movies are going to be the ones
calling the function to ADD another movie, right?

your _root.reset() should work, but why not try

this._parent.reset() inside your changer function...

also try putting a trace("TEST"); inside the reset function on the main timeline, to make sure the children are even calling it. If it doesn't output TEST when you try it, you will know that the problem is the paths from the children to the main timeline.

HTH
MCM

ctarantino
01-11-2006, 03:55 PM
The Child movies are supposed to call a function in the main movie that increments and changes the movie being called, basically a self-incrementing loader so that once its started it doesn't stop. I encountered another problem, it seems that once i call the setInterval function, it just keeps going, and i can't get it to delete. Any Idea???? (i have tried the clearInterval command, but either i am placing it wrong or im not doing it right) any help

Main Movie:

//List of SWF's to be loaded//

var movies:Array = new Array ("1.swf","2.swf","3.swf");

//variables used for incrementing//
var index:Number = -1;

//incrementing function for individual SWF's//
function swf(){

clearInterval(Interval);
index++;
if (index>=movies.length){
index=0;
}
loadMovie(movies[index],loader_mc);
fscommand ("fullscreen",true);
fscommand ("allowscale",true);

}

swf();

function reset(){
var Interval
Interval = setInterval(swf,5000);

}


Child Movie:

this._parent.reset();


Thanks,
Chris

astgtciv
01-11-2006, 08:03 PM
Your var Interval is declared in the scope of the reset() function, it is not visible to the code that calls clearInterval(Interval). You need to move the declaration of var Interval outside of the reset() function.

Check this out as well: http://www.actionscript.org/forums/showthread.php3?t=93367 .