2 Replies - 16301 Views - Last Post: 07 June 2007 - 09:19 AM

#1 gpl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-June 07

How can I detect when a linked movie clip is done playing

Posted 05 June 2007 - 10:04 AM

Objective: to play a linked video file (.flv), then play a linked movie clip (.swf), then play the video file a second time. These 3 events should stream continuously once started

I have figured out how to detect when the video file is done playing so I can start the movie clip. What I need help with is how to determine when the movie clip is done playing so I can start the video clip again. Is there a listener or some kind of trigger that can be passed from the .swf file?

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
stream_ns.onStatus = function(infoObject) {

// check for end of clip1 playing
if (infoObject.code == "NetStream.Buffer.Empty") {
	  

		// play the pause movie clip before playing next clip
	video1_video.clear();
	createEmptyMovieClip("play_mc", 2);
	LoadMovie("pause.swf", play_mc);
	//check for end of movie clip and play next clip
	
}
stream_ns.setBufferTime(3);
video1_video.attachVideo(stream_ns);
stream_ns.play(clip1.flv);




I forgot to mention that I'm using Flash Professional version 7

Is This A Good Question/Topic? 0
  • +

#5 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

Re: How can I detect when a linked movie clip is done playing

Posted 05 June 2007 - 10:59 AM

View Postgpl, on 5 Jun, 2007 - 10:04 AM, said:

Objective: to play a linked video file (.flv), then play a linked movie clip (.swf), then play the video file a second time. These 3 events should stream continuously once started

I have figured out how to detect when the video file is done playing so I can start the movie clip. What I need help with is how to determine when the movie clip is done playing so I can start the video clip again. Is there a listener or some kind of trigger that can be passed from the .swf file?

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
stream_ns.onStatus = function(infoObject) {

// check for end of clip1 playing
if (infoObject.code == "NetStream.Buffer.Empty") {
	  

		// play the pause movie clip before playing next clip
	video1_video.clear();
	createEmptyMovieClip("play_mc", 2);
	LoadMovie("pause.swf", play_mc);
	//check for end of movie clip and play next clip
	
}
stream_ns.setBufferTime(3);
video1_video.attachVideo(stream_ns);
stream_ns.play(clip1.flv);




I forgot to mention that I'm using Flash Professional version 7


i guess you can do an onEnterFrame event like:
_root.myMovieClip.onEnterFrame = function(){
if(this._currentframe >= this._totalframes) _root.playTheVideoFileAgainFunction();
}


Was This Post Helpful? 1

#6 gpl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-June 07

Re: How can I detect when a linked movie clip is done playing

Posted 07 June 2007 - 09:19 AM

Thanks for the reply - I tried the suggestion but could not get the fame information from a movie clip that was being linked to and played. The root flash document was only 1 frame long and the returned total frame kept coming back as 1 as the mc was playing. Or maybe the problems was trying to get frame info from a new blank movie clip - not sure.
So, I brought the mc into the root document so I could play it as needed. I was then able to play the mc and monitor the fame position. However, I cannot get any timeline control functions to work inside my if statement. As a result, the document tried to start replaying and the code in frame one of the action layer started executing again from the beginning, which caused the program to abend.
Next I extended the action layer to the length of the clip and tried putting stop functions near the last frame but those too are ignored. The clip is 122 frames long.

I have trace statements showing when frames 121 and 122 are played. I have a stop function in frame 121 as well as gotoandPlay function in my main script but the document still tries to replay from frame one once it has played.

Now that I know when the mc has finished playing how can I stop it so I can go back and play my video file?

Here's my amended code:


trace ("start");

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
stream_ns.onStatus = function(infoObject) {

// check for end of clip1 playing
if (infoObject.code == "NetStream.Buffer.Empty") {
	  
	trace(infoObject.code);

	// play the pause movie clip before playing next clip
	video1_video.clear();

	//createEmptyMovieClip("play_mc", 2);
	//LoadMovie("pause.swf", Play_mc);

	_root.gotoAndPlay(2);

	//check for end of movie clip and play next clip
	_root.Pause_mc.onEnterFrame = function(){
		if(this._currentframe >= this._totalframes) {
		  tempname = ("cur-frame = "+ this._currentframe);
		 trace (tempname);
		tempname = ("root tot-frames = "+ this._totalframes);
		trace (tempname);

		//stop movie clip 
		_root.Pause_mc.stop();
		trace ("stop");
		}
	}
}
}
stream_ns.setBufferTime(3);
video1_video.attachVideo(stream_ns);
stream_ns.play(clip1.flv);


// OUTPUT
// start 
// NetStream.Buffer.Empty
// cur-frame = 120
// root tot-frames = 120
// stop
// frame 121
// frame = 122
// start
// NOTE.at this point the program abends



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1