Archive for the ‘tutorial’ Category



AS3: gotoAndPlay when an FLV file is finished playing

Tuesday, December 8th, 2009



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

Posted in flash, tutorial | No Comments »