The following example shows how you can dynamically create an instance of the FLVPlayback control, dynamically add an ActionScript cue point, listen for the ready and cuePoint events, and add the FLVPlayback control to the display list, all in delicious ActionScript 3.0.
Full code after the jump.
/** * Requires: * - FLVPlayback control in Library. */ import fl.video.*; var flvPlayback:FLVPlayback = new FLVPlayback(); flvPlayback.x = 10; flvPlayback.y = 10; flvPlayback.addEventListener(VideoEvent.READY, flvPlayback_ready); flvPlayback.addEventListener(MetadataEvent.CUE_POINT, flvPlayback_cuePoint); flvPlayback.source = "http://www.helpexamples.com/flash/video/clouds.flv"; addChild(flvPlayback); function flvPlayback_ready(evt:VideoEvent):void { flvPlayback.addASCuePoint(1, "cuePoint1"); } function flvPlayback_cuePoint(evt:MetadataEvent):void { trace("CUE POINT!!!"); trace("\t", "name:", evt.info.name); // name: cuePoint1 trace("\t", "time:", evt.info.time); // time: 1 trace("\t", "type:", evt.info.type); // type: actionscript }
{ 5 comments… read them below or add one }
Hi Peter,
I’m trying to implement a movie with cue points using your flvPlayback code above. The code works great, but how do i action events to happen when the cuepoints happen?
I want to play a caption mc when cuePoint1 happens over the top of the playing movie
regards
Richard
Richard,
I’d probably add the code to the
flvPlayback_cuePoint()method and put aswitchstatement for the cue point name (usingevt.info.name). Once you know which cue point you’re looking at you can add whatever code you need to attach and position the movie clip asset from the library, or whatever.Something like this:
Peter
ik gebruik onderstaande code om cuepoint toetevoegen aan mijn flv en hiermee actionscript te triggeren.(as 2) wellicht kunnen jullie hier wat mee:
I’ve been trying to add a prevScene(); event when my script has found it’s AS generated cue point. This doesn’t seem to work however, I’ve been playing around with variables as well but to no avail.
I understand this stems from the fact that code embedded in a MC won’t respond to goto or scene commands?
Oh, all this in AS3.0.
Never mind, I’m an idiot.