A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [CS3] (AS2) gotoAndPlay after an external video plays

  1. #1
    Junior Member
    Join Date
    Aug 2008

    [CS3] (AS2) gotoAndPlay after an external video plays

    (Main, 1) Goes to another scene, short animation then plays an external FLV.
    When the video is complete, I want it to go to the main scene, frame 5. gotoAndPlay( "main", 5 );

    How I did it works sometimes and doesn't others. I moved the gotoAndPlay action down the Flash timeline in this scene and by trial and error moved the action 'til the timing was right. The only problem is, if there's a hitch in loading or playback, it cuts away from the video too soon because the Flash timeline and the video timeline are running independently. I need an ActionScript that will gotoAndPlay( "main", 5 ) once the video finishes. I'm not using an AS to play the video, but perhaps should?

    I don't know if it's some kind of command like onvideo complete.
    I've put an event cue point called "videoOver" in the last frame of the FLV video, but I don't know how to get that cue point to trigger the gotoAndPlay. There is probably 2 different ways to accomplish what I want, but I don't know either.

    The problem is in the first 30 seconds.

  2. #2
    Senior Member Ovaire d'Oz's Avatar
    Join Date
    May 2006
    I would advice you by working with this:

    PHP Code:
    ns["onMetaData"] = function(obj) {
    duration obj.duration;
    if (

    Where ns is the net stream where the video is coming from.

    But then, if you are not using any ActionScript, you would probably need to learn more about it first. gotoAndLearn made some very good tutorials about it.

    Note that if duration is divided by one thousand, it is because duration is in miliseconds whereas ns.time returns a value in seconds.
    Last edited by Ovaire d'Oz; 08-11-2008 at 05:48 AM.

  3. #3
    Junior Member
    Join Date
    Aug 2008

    event cue point to trigger gotoAndPlay

    Ovaire, thanks for your answer. I didn't get it to work, but I want to post what did work for me, so perhaps another newbie searching will be helped.

    vid.addEventListener("cuePoint", detectCuePoint);
    function detectCuePoint(event) {
    if(event.info.name == "videoOver") {
    gotoAndPlay("main", 5);

    If someone is searching for this as I was:
    vid = my video instance on the stage
    videoOver = the event cue point I put in my video using the Flash encoder
    "main", 5 = my main scene, frame 5

    I didn't try this one, but I got this code from the same source, so I believe it would probably have worked also. This code listens for the video to complete, which triggers a scene change.

    flv_welcome.addEventListener("complete", changeScene);

    function changeScene() {
    gotoAndPlay("Scene 2");


    I believe fly_welcome is the name of the video instance and Scene 2 is the name of the scene you'd like it to go to after the video.

    Here's where I found my answer:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center