Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a Movie after it has played 2

Status
Not open for further replies.

wilcoHead

Programmer
Feb 2, 2005
85
I have a scripting question.

I have a Movie file (swf) that has another movie (viewer) that plays within it that is streaming a flv file.

After the viewer fades in, plays the streaming file, I want the viewer to go away.

How would I do this without interupting the movie?

Here is my file:

http:\\
Thanks for your input;
WilcoHEAD
 
//var my_net_stream:NetStream;

my_net_stream.receiveAudio(false);
my_new_stream.receiveVideo(false);

should tell the connection to stop sending audio and video through to your player instance.
 
Where would I put this, in the script?


Thanks for your input;
WilcoHEAD
 
how are you detecting the end of the playing FLV file?

I mean, this *could* be as simple as just calling removeMovieClip() on the MC that you load your component into, meaning it will just be removed from the movie all together.

The previous post I made was assuming you had some function for the "stop" action of the movie, in which case you would just drop in those two lines to kill the streaming feed.

you *could* also call net_stream.close();

 
Yes, if you look at the FLA file - Original post Link

I do have a stop, I could try that


Thanks for your input;
WilcoHEAD
 
Oh, well I have 3 layers.

One - Title - Just Frame 5
Two - Movie - Just Frame 5
Three - a Viewing window that fades in - Motion tweening from frame
1 to frame 5 the a "stop();" at frame 5 for the layer three

Thanks for your input;
WilcoHEAD
 
well, i meant a "stop" of the streaming video connection, not the literal stop() function of the flash movie. Two completely different things.

In any case, here are some suggestions from your .fla file:

1. you are gonna have to name your instance of the media display component. This appears on the 5th frame on the layer called "Movie", not on the layer called "viewer" that has the tweening on it.

You notice of course that if your media player component is not actually on the first frame, but the 5th, then the media/video will not "actually" fade in. As it appears right now, your frame around the video (which you call "viewer" by name of the layer) fades in, and then when frame 5 is hit, the media player will be added to the mix inside the "viewer" and start buffering and bring in some video.

2. the name you give the instance of your media-display component is what you will use in actionscript to access the net_stream object and hook into it. you'll want to create an interval with setInterval() which will check (like every 50 mil for instance) to see if the "end" of the video has been reached. when it does, then your interval handler can call any variation of the code suggestions i had above for dealing with stopping/removing the video player.

** in any case, you are gonna need to have at least a basic-to-moderate understanding of actionscript to accomplish what you are hoping to do. If you are not familiar with it, stop first and go get yourself a good book on actionscript before going any further. Otherwise, most of what i'm saying probably makes no sense at all. :)
 
I will go ahead and pick up a book on action script. any suggestions?

Thanks for your input;
WilcoHEAD
 
Flash MX 2004 Actionscript Bible" by Robert Reinhardt and Joey Lott, by Wiley Press.


i recommend that because i prefer reference-style books to learn stuff like this with, rather than tutorial books.

-or-

If you prefer more example/tutorial based teaching (which will necessarily leave out a lot of the nitty gritty details, which in my opinion is the best reason to get a reference book)...

"Macromedia Flash MX 2004 ActionScript : Training from the Source" by Derek Franklin and Jobe Makar, by Macromedia Press.

 
wilcoHead,

If I understood you correctly, you want your "video viewer" to fade out after the video finished playing, right?

1. Click on the frame 10 of the layer "Viewer" and press F6 - this creates a key frame
2. Select the viewer on stage and change the alpha value to 0 - so the viewer fades out from frame 5 to 10
3. Place [tt]stop()[/tt] in the frame 10 - so the playhead won't go back to frame 1 and start again
4. Go to frame 5 and select the MediaDisplay component in the layer "Movie"
5. Name the component in where it says <Instance Name> in the Properties panel - let's name it "videoViewer" for now
6. Append the script in the frame 5 after your [tt]stop()[/tt], so it looks like this:
[tt]//
stop();
//
if (this.videoViewer.playheadTime>=this.videoViewer.totalTime) {
this.gotoAndPlay(this._currentframe+1);
}
//[/tt]

That's all. My first reply to your post was referring to this script, but may be it wasn't clear enough.

Kenneth Kawamoto
 
OK, there’s a handy MediaDisplay.complete event so you can tell the end of your FLV. Apparently MediaDisplay.totalTime is undefined by default according to Macromedia doc. Weird.

Anyway, put this script instead. This works, this time I tested myself!

[tt]//
var listener = new Object();
listener.complete = function() {
_root.gotoAndPlay(_root._currentframe+1);
};
this.videoViewer.addEventListener("complete", listener);
stop();
//[/tt]

Kenneth Kawamoto
 
Hello;

I tried it and I am getting the following errors:
------------------------------------------------
**Error** Scene=Scene 1, layer=Movie, frame=5:Line 24: Statement must appear within on/onClipEvent handler
var listener = new Object();

**Error** Scene=Scene 1, layer=Movie, frame=5:Line 25: Statement must appear within on/onClipEvent handler
listener.complete = function() {

**Error** Scene=Scene 1, layer=Movie, frame=5:Line 28: Statement must appear within on/onClipEvent handler
this.videoViewer.addEventListener("complete", listener);

**Error** Scene=Scene 1, layer=Movie, frame=5:Line 29: Statement must appear within on/onClipEvent handler
stop();

Total ActionScript Errors: 4 Reported Errors: 4
----------------------------------------------------

The movie just keeps on repeating without playing the video clip.

Thanks for your input;
WilcoHEAD
 
You get that error because you applied the script to the MediaDisplay component in the "Movie" layer. You have to apply it to the frame instead. In your original file you placed "stop()" in the frame 5 of the "Viewer" layer - that's where you should put the script I posted. Make sure the Actions panel says "Actions - Frame" when you're applying the script.

Kenneth Kawamoto
 
oops, sorry. I will try it on Monday. Thank you so much for your patience and help.

Eric

Thanks for your input;
WilcoHEAD
 
Perfect! That worked Thanks!

Thanks for your input;
WilcoHEAD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top