[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 976
  • Last Modified:

How do I insert something into SWF file after a FLV is done playing?

I hope I'm asking this question the right way. First  Check out this link please:

http://www.consolidatedsmart.com/beta/

Basically, the SWF file plays an FLV movie when it's first loaded.  The FLV movies IS NOT embedded, it is streamed.  Once the 30 seconds movie is done playing, the screen just goes blank.  How can insert something else there?  At least a picture so once the movie stops playing, instead of just a black screen the user can see a picture.  How about another SWF file?  I have a little slide show that I would love to be able to insert after the movie is done playing.

Thanks for your help.
0
CLSTEAM
Asked:
CLSTEAM
  • 9
  • 8
  • 2
1 Solution
 
RobOwner (Aidellio)Commented:
My first thought is to use javascript.  Have your flash within a <div> if it isn't already so that when the movie finishes playing you can hide it and show in it's place another flash movie like your slide show.

the other though is to have your flash unload the movie when it finishes playing and load your slide show.  In other words create a new "loader" swf that first loads the FLV and then when it finishes playing replaces it with the slide show swf.

What do you think?
0
 
CLSTEAMAuthor Commented:
@ tagit:

Thanks for the reply...I understand what you are saying, but what I need is the actual code, whether javascript or actionscript, to do what you are talking about.  Thanks.
0
 
RobOwner (Aidellio)Commented:
I would personally use the second solution of unloading the movie and loading your slide show swf

Are you using AS2 or AS3?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Aneesh ChopraCommented:
if you are using FLVPlayback component then you should use 'FLVPlayback.complete" event to trigger action after playback completes:

//--------------------------------
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
    // insert event-handling code here
};
my_FLVplybk.addEventListener("complete", listenerObject);
//--------------------------------

0
 
Aneesh ChopraCommented:
similary you can do any action on a specify second of playback using 'FLVPlayback.cuePoint" event

here is the sample code to trigger action on 30 second of playback:

var cuePt:Object = new Object(); //create cue point object
cuePt.time = 30;
cuePt.name = "elapsed_time";
cuePt.type = "actionscript";
my_FLVPlybk.addASCuePoint(cuePt);  //add AS cue point

var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
     trace("Cue at: " + eventObject.info.time + " occurred");
       // add action code here
}
my_FLVPlybk.addEventListener("cuePoint", listenerObject);
0
 
CLSTEAMAuthor Commented:
Aneeshchopra: Thanks, that sounds super complicated but it sounds like what I'm looking for.  Question, in the timeline, on the layer where the movie is, do I insert the actionscript code in the very first frame?
0
 
Aneesh ChopraCommented:
you need to insert this code on the frame of the timeline where FLVComponent component instance resides
0
 
CLSTEAMAuthor Commented:
Hi, I get this error when I insert the code:

1046: Type was not found or was not a compile-time constant: Void.

I'm just testing the code to see if the clip will stop at 5 seconds...
var cuePt:Object = new Object(); //create cue point object
cuePt.time = 5;
cuePt.name = "elapsed_time";
cuePt.type = "actionscript";
my_FLVPlybk.addASCuePoint(cuePt);  //add AS cue point
 
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
     trace("Cue at: " + eventObject.info.time + " occurred");
       // add action code here
	   stop();
}
my_FLVPlybk.addEventListener("cuePoint", listenerObject);

Open in new window

0
 
Aneesh ChopraCommented:
Seems like you need AS3 code,


here is the AS3 version of the above code and it should work for you:



import fl.video.FLVPlayback;
import fl.video.MetadataEvent;
 
my_FLVPlybk.source = "stella_hop.flv";
 
var cuePt:Object = new Object();//create cue point object
cuePt.time = 5;
cuePt.name = "elapsed_time";
cuePt.type = "actionscript";
my_FLVPlybk.addASCuePoint(cuePt);//add AS cue point
 
my_FLVPlybk.addEventListener(MetadataEvent.CUE_POINT, cp_listener);
function cp_listener(ev:MetadataEvent):void {
	trace(ev.info.name);
	trace(ev.info.time);
}

Open in new window

0
 
CLSTEAMAuthor Commented:
Thanks, now I'm getting this error:

1120: Access of undefined property my_FLVPlybk.

I get this error for lines 4, 10 and 12.
0
 
Aneesh ChopraCommented:
you might need to replace "my_FLVPlybk" with your FLVPlayback instance name...
0
 
CLSTEAMAuthor Commented:
Now I get these errors:

Line 4: 1119: Access of possibly undefined property source through a reference with static type Class.
Line 10: 1061: Call to a possibly undefined method addASCuePoint through a reference with static type Class.
Line 12: 1061: Call to a possibly undefined method addASCuePoint through a reference with static type Class.
import fl.video.FLVPlayback;
import fl.video.MetadataEvent;
 
FLVPlayback.source = "http://www.consolidatedsmart.com/beta/movies/intro.flv";
 
var cuePt:Object = new Object();//create cue point object
cuePt.time = 5;
cuePt.name = "elapsed_time";
cuePt.type = "actionscript";
FLVPlayback.addASCuePoint(cuePt);//add AS cue point
 
FLVPlayback.addEventListener(MetadataEvent.CUE_POINT, cp_listener);
function cp_listener(ev:MetadataEvent):void {
        trace(ev.info.name);
        trace(ev.info.time);
}

Open in new window

0
 
Aneesh ChopraCommented:
provided code should work fine, Dont know what are you missing.

Here I have uploaded an AS3 working example for you review:
http://www.4shared.com/file/70582770/db8519d7/FLVPlayback_cuepoint.html
0
 
CLSTEAMAuthor Commented:
The file you gave me works fine...but mine doesn't.  I don't know what it could be.  Thanks for all your help anyway.  One last thing.  Using the other code I get the following error:

Line 3: 1046: Type was not found or was not a compile-time constant: Void.

Is it related?  Come to think of it, this code might serve me better.
//--------------------------------
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
    // insert event-handling code here
};
my_FLVplybk.addEventListener("complete", listenerObject);
//--------------------------------

Open in new window

0
 
Aneesh ChopraCommented:
I suggest to upload your file for review, there is definitely something you might have not explained here.
0
 
CLSTEAMAuthor Commented:
Hi, I really really appreciate all your help.  I must apologize because I think I asked the wrong question.  Searching under "play a swf after another one" I was directed to this question http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_21739381.html which you have answered!  That is a better explanation of what I want to do.  Your answer was to insert the following code:

_root.loadMovie("movie.swf");

Well, it doesn't work on mine because I need ActionScript 3.0 in order to use FLVPlayback...but if you can give me the equivalent of that line in AS 3.0 I think it will solve my problem!  Thanks!
0
 
CLSTEAMAuthor Commented:
Doing some research on google I ran into the attached code.

The code loads "main_pic.swf" from the file that plays the movie, the only problem is that it plays both the FLV movie and the swf file at the same time!   If I can get the swf to start playing after the video plays than my problem would be solved!  Any ideas?  Thanks!

var request:URLRequest = new URLRequest("http://www.consolidatedsmart.com/beta/movies/main_pic.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);

Open in new window

0
 
Aneesh ChopraCommented:
below is the complete code, and your FLVPlayback instance name must be "my_FLVPlybk"

or you can replace all occurance of "my_FLVPlybk" in code below with your FLVPlayback instance name.
import fl.video.FLVPlayback;
import fl.video.VideoEvent;
 
my_FLVPlybk.source = "stella_hop.flv";
 
 
 
my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, cp_listener);
function cp_listener(ev:VideoEvent):void {
	trace(ev);
	// hide video Player instance:
	ev.target.visible = false;
	
	// call function to load external SWF:
	loadExternalSwfNow();
}
 
function loadExternalSwfNow() {
	var request:URLRequest = new URLRequest("http://www.consolidatedsmart.com/beta/movies/main_pic.swf");
	var loader:Loader = new Loader();
	loader.load(request);
	addChild(loader);
}

Open in new window

0
 
CLSTEAMAuthor Commented:
Awesome!  That worked as advertised!  Thanks so much.  The main problem I was having was with the "instance" concept.  I'm new at Flash CS3 and I didn't understand what an instance was and how to name it.  Finally figured it out and it worked perfectly.  Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 9
  • 8
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now