Skip navigation
Currently Being Moderated

Proper method for interactive video

May 24, 2013 12:45 PM

Hi.  It's been a while since I've used Flash/Actionscript, and I've been having trouble figuring out the proper way to do this.  I'm hoping someone here can outline the proper methods.

 

Basically, I'm creating a Flash project where it will play a video, then at a certain point, stop and display some buttons, and then go to the appropriate video based on what button was pressed.  Sort of a choose your own adventure type of thing.

 

Without knowing the current/ideal way of doing it, how I tried it was by having the first video (embedded into the project) on one layer, and at the end of that video, I have a stop()  on another (script) layer (on the last frame of the video in the timeline), and I had the buttons (which appear on top of the video) on another layer at that same frame.  So, in theory, it plays the video, hits the last frame, stops the timeline, and waits for one of the buttons to be clicked.  Each button triggers and gotoAndPlay(), which takes the timeline to one of the other two videos that are located one after the other, after the first video, on the same (video) layer.

 

Problem is, I have a bit of a catch-22...  I was aware that there would be sync issues between the video and it's audio (addressed by doing the audio as Sync or something in the audio properties)... however, I was suprised to see that the video does not maintain sync with the other layers (script).   So, what happens is that it plays the video, but SEEMS to play it faster than the script layer, so it reaches the end of the video before reaching the (identical frame) location of the actionscript.  As a result, the video loops, and the stop() is hit sometime during the start of the second playing of the video.  The buttons act similar, appearing sometime AFTER the point in the video where they should.

 

I had embedded the video with the assumption that this would give me hard sync between it and the timeline, since it's physically there in the timeline, and you can see the frame at which it ends... and I thought then putting a stop() on that frame (but on a different layer), would guarantee that the stop code gets hit at the same time the end of the video was.

 

I've tried a number of things, like putting the actionscript code on the frame after the video on the same layer, figuring a single layer can't go out of sync with itself... but that didn't work either.

 

Looking into it, I saw that one option was to not embed the video, but to have it reference an external file (which, supposedly, would result in no sync issues).  But, in doing that, I'm not aware of how the rest of the timeline would know when the video has reached certain spots of the video.

 

I'm sure the proper method is entirely different from what I'm doing, but I'm not familiar with other methods.  I'm hoping someone can outline the proper procedures (in as much detail as possible, since I probably won't know about much of what you are explaining).

 

Keep in mind, again that this is basically what I want to do:

 

-Play video 1

-Stop timeline, display buttons, wait for response

-Based on which button is pressed, jump in the timeline to video 2 or 3 (...I'm assuming all the vids will be on one layer, one after the other, with a label at the start of each one)

 

Hope you can help.  Thanks.

 
Replies
  • kglad
    72,166 posts
    Jul 21, 2002
    Currently Being Moderated
    May 24, 2013 1:26 PM   in reply to Laer2

    use an flvplayback component to play your videos.

     
    |
    Mark as:
  • kglad
    72,166 posts
    Jul 21, 2002
    Currently Being Moderated
    May 24, 2013 2:31 PM   in reply to Laer2

    did you add an flvplayback component to the stage?

     

    did you assign its source using actionscript or in the  properties panel (with the component selected)?

     
    |
    Mark as:
  • kglad
    72,166 posts
    Jul 21, 2002
    Currently Being Moderated
    May 25, 2013 10:07 AM   in reply to Laer2

    yes, the flvplayback component will be on one frame (eg, on your main timeline) and that timeline will not advance, if ever, without some actionscript executing.

     

    if you want the component to trigger some action at the end of the video, you will use add a listener for the videos end.  if you want to trigger some action during the video, you will add cuepoints to the video, and a cuepoint listener to detect those cuepoints.

     

    if you want both, you will add both listeners.

     

    now, which listener do you want to add and what do you want to happen when that event is detected?

     
    |
    Mark as:
  • kglad
    72,166 posts
    Jul 21, 2002
    Currently Being Moderated
    May 25, 2013 3:10 PM   in reply to Laer2

    -A video plays (Intro video)

    -After that video, a looping video plays, with buttons (Scene selection thumbnails) on top of it (Selection menu with looping background)

     

    add an flvplayback component to your frame 1stage and assign it an instance name (in the properties panel), eg, flv_pb.  in the properties panel, use:

     

    flv_pb.source="yourpath/yourintroflv.flv";

    flv_pb.addEventListener(Event.COMPLETE,introCompleteF);

     

    function introCompleteF(e:Event):void{

    flv_pb.removeEventListener(Event.COMPLETE,introCompleteF);

    flv_pb.source="yourpath/yourloopingvideo.flv";

    flv_pb.addEventListener(Event.COMPLETE,loopCompleteF);

    }

    function loopCompleteF(e:Event):void{

    flv_pb.seek(0);

    flv_pb.play();

    }

     

    ////////////////////////////////////////////////////////// that's enough to get you started. let me know if you have a problems, so far.

     
    |
    Mark as:
  • kglad
    72,166 posts
    Jul 21, 2002
    Currently Being Moderated
    May 25, 2013 3:41 PM   in reply to Laer2

    you're welcome.

     

    (and, if you have no problems with that, let me know and we'll continue with the rest of your project.)

     
    |
    Mark as:
  • kglad
    72,166 posts
    Jul 21, 2002
    Currently Being Moderated
    May 28, 2013 3:03 PM   in reply to Laer2

    the intro and loop are all in frame 1.

     

    just add an flvplayback component to your frame 1stage and assign it an instance name (in the properties panel), eg, flv_pb.  in the properties panel, use:

     

    flv_pb.source="yourpath/yourintroflv.flv";

    flv_pb.addEventListener(Event.COMPLETE,introCompleteF);

     

    function introCompleteF(e:Event):void{

    flv_pb.removeEventListener(Event.COMPLETE,introCompleteF);

    flv_pb.source="yourpath/yourloopingvideo.flv";

    flv_pb.addEventListener(Event.COMPLETE,loopCompleteF);

    }

    function loopCompleteF(e:Event):void{

    flv_pb.seek(0);

    flv_pb.play();

    }

     
    |
    Mark as:
  • kglad
    72,166 posts
    Jul 21, 2002
    Currently Being Moderated
    May 28, 2013 3:39 PM   in reply to Laer2

    then add flv_pb1 to frame 1 and use:

     

    flv_pb1.source="yourpath/yourintroflv.flv";

    flv_pb1.addEventListener(Event.COMPLETE,introCompleteF);

     

    function introCompleteF(e:Event):void{

    gotoAndStop(2);

    }

     

    and add flv_pb2 to frame 2 and use:

     

     

    flv_pb2.source="yourpath/yourloopingvideo.flv";

    flv_pb2.addEventListener(Event.COMPLETE,loopCompleteF);

    }

    function loopCompleteF(e:Event):void{

    flv_pb2.seek(0);

    flv_pb2.play();

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points