PDA

View Full Version : next frame after movie


ben_rees
01-19-2008, 10:57 AM
hi, im reletivly new to action script and i am makind=g a website for uni and need to know how to make my movie go to the next frame when it has finished..it is an flv movie dynamicly loaded into flash and i am using it as an intro to my website. ive put a stop comand on the frame the movie loads to so that it will play the movie all the way through but when it finishes it just stops, i want to know how to code it to get it to go to next frame when it has finished playing, if anyone could help me i would be very greatfull, thanks...

Paul Ferrie
01-19-2008, 11:26 AM
What object are you using to play the flv? Video embed or the flvPlayBack component?

ben_rees
01-19-2008, 12:00 PM
im using the flvplayback component to play the video in the master flash file

Paul Ferrie
01-19-2008, 12:13 PM
var listenerObject:Object = new Object();
listenerObject.stopped = function(eventObject:Object):Void {
// insert event-handling code here
};
my_FLVplybk.addEventListener("stopped", listenerObject);


It's in the manual (http://livedocs.adobe.com/flash/9.0/main/00003083.html)

ben_rees
01-19-2008, 12:20 PM
yeah i tried that testerday and it didnt seem to work is there another way i could do it?

Paul Ferrie
01-19-2008, 12:26 PM
That is the way you do it.
Check the the component instance name matches that in the code my_FLVplybk

ben_rees
01-19-2008, 12:27 PM
cheers mate

janjan32
09-24-2008, 07:26 PM
I need code to get this working for as3. This doesn't work, it just stops and doesn't got to my frame label "alice" anyone have any ideas?
thanks!

/**
Requires:
- FLVPlayback component on the Stage with an instance name of my_FLVPlybk
stop();
//as 2.0
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
_root.gotoAndStop("alice");
};
my_FLV1.addEventListener("complete", listenerObject);
my_FLV1.contentPath = "holder.flv";*/

//actionscript 3.0
this.stop();

import fl.video.*;

var flvPlayer:FLVPlayback = new FLVPlayback();
addChild(flvPlayer);

flvPlayer.source = "http://www.helpexamples.com/flash/video/water.flv";

video1.addEventListener(VideoEvent.COMPLETE, onPlaybackComplete);

function onPlaybackComplete(ev: VideoEvent):void {
gotoAndStop("alice");
}

webslinger00
09-26-2008, 01:13 AM
Hi,
I was wondering if an answer was ever given for this? I've looked all over the board and this is the only one that I could find that fits what I am trying to do.

I want to be able to detect the end of the FLV then go to play the next frame.

Can anyone help?

Thank you in advance.

pierre23
09-26-2008, 01:27 AM
var listenerObject:Object = new Object();
listenerObject.stopped = function(eventObject:Object):Void {
// insert event-handling code here
};
my_FLVplybk.addEventListener("stopped", listenerObject);


It's in the manual (http://livedocs.adobe.com/flash/9.0/main/00003083.html)

It has been answered ^

edit; oh you mean for AS3 question?

atomic
09-26-2008, 01:39 AM
AS3.0?

http://www.actionscript.org/forums/showthread.php3?t=182538

webslinger00
09-26-2008, 02:00 AM
Hi, thanks for the response. Let me clarify, I'm working with AS2.

I'm still getting familiar with AS so I'm not too sure about the structure of it and what I need to change. I'm using an FLV playback component on Frame 1. Once the FLV has finished playing, I want to detect the end of the FLV then gotoandplay frame 2. Thanks for the link to the manual, I can check it out too. However, I was wondering if someone could provide the script and point out what parts need to change (if possible).

Thanks again in advance. I promise to return the favor if I can in the future.

atomic
09-26-2008, 02:05 AM
Use this...

http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00003537.html

And rather than just a trace in the listener, add...

_level0.gotoAndStop(2); //Or gotoAndPlay(2), if you want it to play from frame 2...

webslinger00
09-26-2008, 02:15 AM
Hi Atomic,
Where in the AS below would I add the "goto" line? Thanks a bunch!

---------------
/**
Requires:
- FLVPlayback component on the Stage with an instance name of my_FLVPlybk
*/
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
trace("Elapsed play time at completion is: " + my_FLVPlybk.playheadTime);
};
my_FLVPlybk.addEventListener("complete", listenerObject);
my_FLVPlybk.contentPath = "FLV URL here";
---------------

atomic
09-26-2008, 04:39 AM
Right after the trace action...
That way you'll know if thelistener fires at the end of the video...

matteus
09-26-2008, 08:34 AM
This is exactly what I'm after! I was waiting for a better reply on this thread yesterday for as2.0 instead of as3.0.

I now know the differences between FLVPlayback component and netStream, so basically there's a about a 32k overhead and FLVPlayback will handle buffering and loading... Which is handy.

However:

I'm not using any skin as I don't want users to control the video.

I have an intro movie that plays, during which a logo appears. After this finishes I'd like to seamlessly load another movie that loops the logo animation without any signs of a switch having been made.

I'm guessing I'd need to fully load both movies before playing, Is this even possible with FLVPlayback or will I have to resort to using more code to handle everything?

atomic
09-26-2008, 03:11 PM
I'd use a netStream, and preload both videos before playing the movie...

matteus
09-26-2008, 03:59 PM
I found this example of how to do netstream, I'm just not sure how i'd use it to buffer both instances at once then play one, then play the other in a loop...

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(5);
ns.onStatus = function(info){
if(info.code == "NetStream.Buffer.Full"){
bufferClip._visible = false;
}
if(info.code == "NetStream.Buffer.Empty"){
bufferClip._visible = true;
}
if(info.code == "NetStream.Play.Stop"){
ns.seek(0);
}

}
theVideo.attachVideo(ns);
ns.play("splash-screen-intro.flv")
ns.close()

atomic
09-26-2008, 04:04 PM
I wasn't talking about buffering, but of completely preloading both videos, before the movie plays...

matteus
09-26-2008, 04:05 PM
I'm 100% new to this sorry!

I've got the basic structure its all working...... I'm just now attempting to proof it to stop it breaking :(

So anyhow how would i load them both on the same frame one following the other then allow it to loop?

Thank you for your help it is greatfully recieved

atomic
09-26-2008, 04:08 PM
Attach your .fla and provide a link to both .flv's.

matteus
09-26-2008, 04:29 PM
fantastic all sorted!!!

FRAME 1 CODE:

stop();
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
theVideo.attachVideo(stream_ns);
stream_ns.play("splash-screen-intro.flv");

this.createTextField("loaded_txt", this.getNextHighestDepth(), 10, 10, 160, 22);
var loaded_interval:Number = setInterval(checkBytesLoaded, 500, stream_ns);

function checkBytesLoaded(my_ns:NetStream) {
var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
loaded_txt.text = Math.round(my_ns.bytesLoaded / 1000) + " of " + Math.round(my_ns.bytesTotal / 1000) + " KB loaded (" + pctLoaded + "%)";
progressBar_mc.bar_mc._xscale = pctLoaded;
if (pctLoaded >= 100) {
clearInterval(loaded_interval);
}
}

stream_ns.onStatus = function(info){
if(info.code == "NetStream.Play.Stop"){
gotoAndPlay(2);
}
}

FRAME 2 CODE:

stop();
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
theVideo.attachVideo(stream_ns);
stream_ns.play("splash-screen-loop.flv");

this.createTextField("loaded_txt", this.getNextHighestDepth(), 10, 10, 160, 22);
var loaded_interval:Number = setInterval(checkBytesLoaded, 500, stream_ns);

function checkBytesLoaded(my_ns:NetStream) {
var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
loaded_txt.text = Math.round(my_ns.bytesLoaded / 1000) + " of " + Math.round(my_ns.bytesTotal / 1000) + " KB loaded (" + pctLoaded + "%)";
progressBar_mc.bar_mc._xscale = pctLoaded;
if (pctLoaded >= 100) {
clearInterval(loaded_interval);
}
}

stream_ns.onStatus = function(info){
if(info.code == "NetStream.Play.Stop"){
stream_ns.play("splash-screen-loop.flv");
}
}

atomic
09-26-2008, 05:39 PM
And this works online, when the .flv's are not already cached?

matteus
09-27-2008, 10:26 AM
yup ok i was wrong its caching it as it plays....

It doesn't infact work at all just shows you how much its downloaded as it plays good old adobe describing an example wrong

atomic
09-27-2008, 01:43 PM
So Is it working or not?

matteus
09-30-2008, 11:14 AM
After a bit of playing yes it did indeed work :) I setup a 60 second buffertime this meant the flv was 100% loaded before playing.

Mmm I don't think this is going to be quite enough for what I'm current developing though.

What I really need is a way to load 10 small 150kb movies into memory before playing the first and show a loader bar for these, so the user isn't completely baffled.

Thanks for your help thus far atomic, sorry I'm being protective over the fla's. What I'm developing is pretty cool and I'm trying my best not to leak any details yet.

atomic
09-30-2008, 01:29 PM
When one wants to protect content, but still needs help, one would put together a small mockup .fla with fill in content, and provide that...

But too late, for me at least, if you ever provided it...

matteus
09-30-2008, 02:16 PM
cheeky moose :) i'm not being up my arse about it...

I just know someone could throw what I'm putting together in 10 minutes hehe

janjan32
09-30-2008, 02:44 PM
I got it working you can download my file from this post.
http://www.actionscript.org/forums/showthread.php3?t=184484

dondada
11-01-2008, 02:51 PM
var listenerObject:Object = new Object();
listenerObject.stopped = function(eventObject:Object):Void {
gotoAndPlay(2);

};
flick.addEventListener("stopped", listenerObject);

"flick" is the name of my FLVPlayback component

I got 3 compiler errors for lines of code THAT DIDN'T EVEN EXIST.

there's 6 lines of code (copy and pasted that code) and the compiler errors referenced lines "17, 18, and 22" in the components code THAT'S ONLY 6 LINES LONG.

I would love to see what code worked for this. I'm still preplexed, all I wanted to make was an "enter site" button on frame 2. I can't get the playhead to make it to frame 2.

I'm using Actionscript 2.0 and all I have is 2 frames with 3 layers

Actions: First frame has stop();
Shape: second frame has a rectangle drawn on stage
Movie: has one frame with an FLVPlayback component pointing to my movie there's nothing else there.