PDA

View Full Version : Images following video


CPedrick
03-07-2008, 03:06 PM
I have a video clip that I want to run and, when it is finished, followup with some other images and effects on the Flash timeline.
Any thoughts on how best to do that?
TIA,
Carolyn

dannyhouk
03-07-2008, 04:29 PM
First, how is your video being used in Flash? Are you using the FLVPlayback component, netStream class, or just embedding?

I'm working with a very similar situation. You could add an actionscript cue point for the end of your video, then create an event listener that "listens" for when the cue point is reached and then you script a command to load/display your image/effects. Here is an example lifted from my project that would work if you're using the FLVPLayback component to load your flv:

// this will dynamically create a cue point for the flvplayback component
// with instance name "my_flvPB" the number in parenthesis is the time in
// seconds that your video ends and the "end" is an arbitrary name for the cue point
my_flvPb.addASCuePoint(45, "end");

// this is the listener object which "listens" for when the cue point titled "end"
// is reached in the video and then will perform whatever action you want
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(evt:Object):Void {
if (evt.info.name == "end") {
myMovieClip.gotoAndStop("label1");
};

Again, this example only works if you're handling your video using the FLVPlayback component (which is what I'm using). In the section of code that says "myMovieClip.gotoAndStop("label");" you would put whatever function in that place that would trigger your image or effects. In my case, I have a move clip instance named "myMovieClip" goto a frame labeled "label1" and on this frame could be an image, animation, etc.

Hope this makes sense, repost if you still want help/need clarification.

CPedrick
03-10-2008, 07:28 PM
Thanks very much! I'm almost there.
Here's the code I am using and it works great:


import mx.video.*;

// specify name and location of FLV for default player
import mx.video.*;
my_FLVPlybk.contentPath = "http://www.nldev4.com/Flash/MJ_video/mj_presclub-in.flv";
// create cue point object
var cuePt:Object = new Object(); // create cue point object
my_FLVPlybk.addASCuePoint(28.31, "ASCuePt1"); //sets cue point 28.31 secs from start of video

//add listener for queue point
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
myPics_mc.gotoAndPlay("photos")
};
my_FLVPlybk.addEventListener("cuePoint", listenerObject);

This plays the movie clip quite nicely when the preliminary video finishes.
Now, however, I want to end with another movie clip. Do you know how I can then play a different .flv in the same playback component?

Thanks very much again,
Carolyn

dannyhouk
03-11-2008, 06:01 AM
Glad that worked (I'm also glad you found out the scripting yourself, I see I left off the addEventListener syntax in my example :) Bear in mind that I'm a novice who just tries to get it done, don't always know the most elegant solution.

Not clear on your next challenge. After the first flv reaches the ASCuePt1 and goes to the mc frame, do you also want the next flv to immediately load into the same playback component? If this is the case, have you tried just putting another line my_FLVPlybk.contentPath = "nextvid.flv"; in the line underneath myPics_mc.gotoAndPlay("photos");? That should replace the current flv with whatever you specify (never tried this, if it doesn't work just lookup flvplayback in livedocs for the correct function, I know it exists).

Or do you want the myPics_mc that plays from your first flv to play through and after reaching a certain frame THEN you load another flv? In that instance you might be able to use currentframe to check when the myPics_mc reaches your desired frame and then script another flv to load into the component.

Any other suggestions out there?