all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

Loading multiple movies in sequence


Loading multiple movies in sequence wendigo
10/18/2006 8:11:43 PM
flash actionscript:
I'm trying to make multiple movies show through a main file in sequence
(slide0.swf, slide1.swf, slide2.swf etc etc).

I've been using some fla document that was sent to me to do such a thing but
somehow I can't get things to work exactly as intended.

My main file/movie uses these pieces of actionscript to do the loading of the
sequential files/movies

(Frame 1)


//initialize
var delay:Number = 5;
var numImages:Number = 3;
delay=delay*1000;
// Randomize array
Array.prototype.shuffle = function() {
var len = this.length;
var temp, rand;
for (var i = 0; i<len; i++) {
rand = Math.floor(Math.random()*len);
//swap current index with a random one
temp = this[i];
this[i] = this[rand];
this[rand] = temp;
}
};
var list:Array = new Array();
var buildArray:Function = function (len:Number) {
for (var i = 0; i<len; i++) {
_root.list.push("./SPW/slide"+i+".swf");
}
_root.list.shuffle();
_root.list.shuffle();
};
buildArray(numImages);
//IDX Watcher
var IDX = "";
function changeIDX(prop, oldVal, newVal) {
if (oldVal != newVal) {trace(list[newVal]);
loadme.loadClip(_root.list[newVal], _root.top);
return newVal;
} else {
return oldVal;
}
}
function addIDX(){
_root.IDX=(_root.IDX+1)%_root.numImages;
}
//MovieClip Loader
var loadme:MovieClipLoader = new MovieClipLoader();
var loadbtm:MovieClipLoader = new MovieClipLoader();
var listen:Object = new Object();
listen.onLoadInit = function(mc:MovieClip) {
mc.play();
_root.myInterval=setInterval(doInterval,delay);
};
listen.onLoadComplete = function(mc:MovieClip) {
loadbtm.loadClip(list[(IDX+1)%numImages],_root.btm);
};
var doInterval:Function = function(){
_root.top.play();
clearInterval(myInterval);
}

loadme.addListener(listen);
_root.watch("IDX",changeIDX);


(Frame 2)

IDX=0;

(Frame 8)

setInterval
stop();

__________________________________________

Now if I do not add anything to my other clips, the main file just keeps
looping the first one over and over rather than going up through them all
sequentialy. So I tried addind this in the last frame of each of the
movies/clips to be displayed

(Last Frame)

_root.addIDX();

___________________________________

The problem I now have is that although now the movies are playing one after
the other sequentialy I still get a small amount of repeat (fraction of a
second) of the movie that just played before the newly loaded one displays.

Is there a way that I can make this transition work smoothly rather than have
a jerky moment of flashback before each new movie in the sequence starts
playing?

Thanks
Re: Loading multiple movies in sequence TimSymons
10/20/2006 4:49:43 PM
What about adding a stop() action too.

stop();
_root.addIDX();

That way the current movie won't automatically loop to the beginning and start playing again.

Re: Loading multiple movies in sequence wendigo
10/20/2006 6:35:39 PM
Re: Loading multiple movies in sequence TimSymons
10/20/2006 6:53:02 PM
Couple of things I would check.

1) In Frame 8 you say you have the following code:

setInterval
stop();

Is the setInterval supposed to be there?

2) In you "doInterval" function you are using the clearInterval function but I
am not certain that you are using the correct path the to "myInterval"
variable. You may want to change it to read:

var doInterval:Function = function(){
_root.top.play();
clearInterval(_root.myInterval);
}


Tim

Re: Loading multiple movies in sequence wendigo
10/20/2006 7:10:52 PM
Thanks for the help Tim, it's greatly appreciated. I've applied your change to
the doInterval function as well as test what the removing the setInterval on
frame 8 would do. Even after these I get the same display issue/problem.

I'm including a link to a test page showing the sequence here so you may see
visualy what it is I'm trying to fix. The seeing it may help make more sense of
it than the way I have explained it.

http://192.197.118.103/spwslides.html

Once again, thanks for taking the time to try and help me out.
Re: Loading multiple movies in sequence TimSymons
10/20/2006 7:38:03 PM
It looks like you are loading 2 clips so that when one is finished the next one
will play without delay and then it loads the next in the series beneath it.

The flash that I am seeing is from the one that is hidden. Before it begins to
play, the next movie is loaded and you see it, then they play in the correct
order.

Try placing the code you have in the onLoadComplete event into the onLoadInit
event. Like this:

listen.onLoadInit = function(mc:MovieClip) {
mc.play();
_root.myInterval=setInterval(doInterval,delay);
loadbtm.loadClip(list[(IDX+1)%numImages],_root.btm);
};

And comment out the following:

//listen.onLoadComplete = function(mc:MovieClip) {
// loadbtm.loadClip(list[(IDX+1)%numImages],_root.btm);
//};


The onLoadComplete event gets called first and starts loading your next slide
before the onLoadInit event gets called. This small delay maybe enough to be
causing the flash you are seeing.

Tim
Re: Loading multiple movies in sequence wendigo
10/23/2006 2:03:06 PM
I've switched the function to the onLoadInit instead of where it was in the
onLoadComplete as suggested. But no chance there as I am still getting the same
pattern with the delay in the sequence of clips being played.
Re: Loading multiple movies in sequence wendigo
10/23/2006 2:24:03 PM
I went through the code once more and inverted the couple of calls to function being done in the onLoadInit area and it now works the proper way.

AddThis Social Bookmark Button