I know this question has been answered in several forms on this forum, but I haven't been able to find an answer that works in my case.
I have 6 movies that I want to load in to a swf and I want movie #2 to start playing when movie #1 is done, and so forth. I have tried this code, but it just replays the first movie again and again.
Code:
var tut01:tutorial01 = new tutorial01();
var target:DisplayObject;
var startTime:Number;
var duration:Number;
addChild(tut01);
tut01.play();
function clipDuration (duration:Number):void {
tut01.duration = duration;
target.addEventListener(Event.ENTER_FRAME, enterFrameListener);
}
function enterFrameListener (e:Event):void {
var elapsed:Number = getTimer()-startTime;
var percentDone:Number = elapsed/duration;
if (percentDone == 1) {
gotoAndPlay("tutorial02");
target.removeEventListener(Event.ENTER_FRAME, enterFrameListener);
}
}
I have created six frames in the swf that is loading these movies (one for each movie), that's what the 'tutorial02' is referring to.
Thanks for your help. That kind of works...they do play one right after the other, but it looks like it starts playing the next clip a few seconds in instead of from the beginning. Any ideas?
I had this exact same problem. I found my solution at another flash board.. here's the code you need. Please don't ask me how to explain it to you.. thus it's a bit over my head.
Create a new flash movie at 25 frames per second.. in the first keyframe insert this code:
// **code starts
function ClipSLoader(target_mc) {
var _ts = this;
_ts.mcContainer = target_mc.createEmptyMovieClip("theContainer", 0);
_ts.onClipEnd();
}
ClipSLoader.prototype.checkIfEnd = function() {
var _ts = this;
var _mcc = _ts.mcContainer;
if (_mcc.getBytesLoaded() == _mcc.getBytesTotal() && _mcc.getBytesTotal()>4) {
if (_mcc._currentframe == _mcc._totalframes) {
var mcS_array = new Array(["TVExhibits.swf"], ["Part03.swf"], ["DataEntry04.swf"]);
var mcIndex = 0;
myLoader.loadClip(mcS_array[0]);
myLoader.onClipEnd = function() {
// load the next swf;
if (mcIndex<mcS_array.length-1) {
++mcIndex;
myLoader.loadClip(mcS_array[mcIndex]);
clearInterval(this.checkIfEndingID);
//mcIndex++;
} else {
mcS_array = null;
clearInterval(this.checkIfEndingID-1);
myLoader.loadClip(mcS_array[mcIndex]);
}
};
// **code ends
You must replace this info :var mcS_array = new Array(["TVExhibits.swf"], ["Part03.swf"], ["DataEntry04.swf"]); with the name of your .swf files you want to load in sequential order.
Thanks Mystique and sstadler. I thought that looked like AS 2.0...I'll try and see if I can convert it to AS 3.0 and get it to work. I'll let you all know how it turns out.