The problem with FLVs is they have to be on Frame 1 of the movie timeline.
To play them consecutively this worked for me.
First of all we'll be working with Action Script 2 and the FLVPlayback component, so you have to be using Flash 8 or higher.
For a test example create a flash file for each of your FLVs
Call the first one flv1.swf the second flv2.swf and the third flv3.swf and add your flvplayback component and appropriate flv to each on frame one of layer one
*note* - save all files to the same root directory of the folder you are working in.*important to note* In order for what I'm going to show you to work, when encoding your FLVs you need to add two cuepoints. At the very beginning of the movie add a cuepoint and call it "begin" with a type of "navigation". Then scrub to the end of the movie and give it a cuepoint and give it a name of "end" with a type of "event" (navigation would also probably work but I usually use event - I've gotten into the habit of doing this with all my FLV's when I encode them so that at the very least I have a beginning and ending cuepoint. - if your flv's don't have cuepoints encoded, you can "create" them with action script and event listeners, but it's a good bit more complicated.)Then create a new movie and call it main.swf and give a name of your choice to layer 1
and then add a new layer and call it labels, and then add an actions layer.
On all layers add a keyframe at frame 10 and one at frame 20 and one at frame 30 (you could do it on just frame 2 and 3 but you're going to want to label frame 1,10 and 20 and putting your keyframes there will let you be able to see/read your labels.
Let's start with frame 1 of main.swf
on your labels layer, create a label for frame 1and call it "movie1", frame 10 label it "movie2", and frame 20 "movie3".
click frame 1 of your actions layer and open your actions panel.
Copy this code
stop();
if(xx == 1)
{
gotoAndPlay('movie2');
}
else
{
loadMovie("movie1.swf",1);
}
- stop();
- if(xx == 1)
- {
- gotoAndPlay('movie2');
- }
- else
- {
- loadMovie("movie1.swf",1);
- }
Lets break that down.
if(xx == 1) // here we are going to set up an if statement to test for the value of "xx".
(In just a moment, we are going to set up a global variable in flv1.swf and set the value of xx equal to 1 so don't worry about where that value is coming from for now).
So when we enter frame 1 of main.swf and xx already has a value of 1 we're going to skip this frame and gotoAndPlay frame 10 (i.e. label movie2). Otherwise we are going to load movie1.swf at level 1 and play your first FLV.
Now open your FLA for movie1 that you created.
Add an actions layer above your FLV Component layer.
Copy this code:
stop();
_global.xx = 1;
import mx.video.*;
var listenerObject1:Object = new Object();
listenerObject1.cuePoint = function(eventObject:Object):Void {
var cuePtName = eventObject.info.name;
if (cuePtName == "end") {
my_FLVPlybk.loadMovie("main.swf",1);
//trace("Elapsed time in seconds: " + my_FLVPlybk.playheadTime);
//trace("Cue point name is: " + eventObject.info.name);
//trace("Cue point type is: " + eventObject.info.type);
}
};
my_FLVPlybk.addEventListener("cuePoint", listenerObject1);
- stop();
- _global.xx = 1;
- import mx.video.*;
- var listenerObject1:Object = new Object();
- listenerObject1.cuePoint = function(eventObject:Object):Void {
- var cuePtName = eventObject.info.name;
- if (cuePtName == "end") {
- my_FLVPlybk.loadMovie("main.swf",1);
-
- //trace("Elapsed time in seconds: " + my_FLVPlybk.playheadTime);
- //trace("Cue point name is: " + eventObject.info.name);
- //trace("Cue point type is: " + eventObject.info.type);
- }
- };
- my_FLVPlybk.addEventListener("cuePoint", listenerObject1);
Let's break that down:
_global.xx = 1; // remember I said we were going to set the value of xx in our flv1 movie and here's where we do it. We want to make it global so it's available throughout.
Next we create a listener object and call it "listenerObject1" If you've worked with listener objects that function should look pretty familiar.
*Please Note* For this example, I named my FLVPlayback instance with an instance name of my_FLVPlybk (careful with the spelling). If you have a different instance name for your FLV then change each occurance of my_FLVPlybk about to your instance name.)If you want to you can uncomment the traces to see what's happening.
OK, so what are we doing here.
When our movie main.swf plays for the first time, flv1.swf hasn't been loaded yet, so the value of xx is null, and as a result we load flv1.swf and start playing it. At the same time we are globally setting the value of xx to 1. as the flv comes to it's end, the event listener picks up the cuepoint "end" and loads main.swf at level one - it's important to keep the level consistently the same, otherwise you might find your flv1 continuing to play at the same time your flv2 does, etc.
Once we've returned to main.swf, this time in frame 1 the value of xx is now 1 so instead of playing flv1 again, now we skip to frame 10 (label movie2).
Are you following the logic?
Now you want to repeat the process above with flv2, only this time for your global variable instead of xx, use yy so we don't confuse things.
Also, in your FLV2 actions, in addition to setting _global.yy = 1; You will also want to reverse what you've done to FLV1 and set _global.xx = 0;
(*note* if you don't do this, your value of xx will remain 1 in which case, movie1 will never play again - however where you set this is important - I'll let you play with it a bit to see if you can figure out where and why).
That should be enough for you to work through to where you can get the entire thing to play continuously. Just follow the same logic for FLV3.
Now as far as buttons, add a new layer to main.swf for you buttons.
I'll let you work through the buttons yourself, but basically, for your button actions onRelease, you are going to need to unload the currently playing movie before you gotoAndPlay the next movie, otherwise they'll be playing on top of each other.
I'll let you work with those ideas. If you have any questions or get stuck just ask.
*one last important note* Realize that if you copy the exact code from flv1 actions to your flv2 movie it isn't going to work. Why? because you are loading main.swf after movie 2 plays and it's going to start playing at frame1 of main, not frame 10. and also because you need to globally set the yy variable not the xx variable. Let's see if you can figure out how to get it to return to frame 10. (refer to my note above about setting the global value of xx to 0 as a hint) 