AS3: gotoAndPlay when an FLV file is finished playing



THE PROBLEM:
So, I recently created a showcase reel that involves several flvs with transitions between. For various reasons, I had to make this a timeline based animation. I was running into a problem with latency because of download times and the flvplayback component. The flvs would play and the transitions between the flvs would occur really late.

THE SOLUTION:
Add an event listener to the flv instance and listen for COMPLETE.

Step 1: Import your FLV files and place on stage with the correct # of frames between them. (Take the length of your FLV file, multiply by the FPS of your FLA file: that is how many keyframes that particular FLV should have on the timeline.)


Select File > Import to Stage > Your FLV file name
(There are lots of options when importing FLV files. Select what is appropriate for your project.)


Step 2: Give your flvs instance names ( for the first FLV, I chose the very creative instance name flv1)

Step 3: Create a new layer, name it labels

Step 4: Set a keyframe on for the first frame of each flv file and give a label name on the properties tab

Step 5: Create an actions layer, create a keyframe for the first frame of each flv file (just like you did for the label names)

Step 6: Import the VideoEvent.
On the first frame of the Actions layer place this code:

import fl.video.VideoEvent;

Step 7: Add this code to each key frame, changing the instance name, function name and gotoAndPlay() label name.

flv1.addEventListener(VideoEvent.COMPLETE,videoOver1);

function videoOver1(e:VideoEvent)
{
gotoAndPlay(”part2″);
}



quicktime

VIEW THE TUTORIAL : On FLV Complete gotoAndPlay()





READ MORE ABOUT the FLVPlayBack component



This entry was posted on Tuesday, December 8th, 2009 at 1:10 pm and is filed under flash, tutorial.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.



Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • « Older Entries
  • Newer Entries »