Groups | Blog | Home
all groups > flash actionscript > september 2006 >

flash actionscript : FLV Event Cue Point...Just can't get it?



SMB
9/28/2006 12:51:02 PM

[quoted text, click to view]

I did something similar to this a long time ago. There is some method in
the FLVPlayback component that returns the current playhead time.

So, you could run some sort of looping function (onEnterFrame and
setInterval come to mind) which checks the current playhead time. Then, it
would check against your values for the "cue points" and jump ahead.

Something like... (not tested)

var cueData:Array = [ {cue_time: 12.0, frame_label: "frame 2"}, {cue_time:
24.0, frame_label: "frame 3"}];
var cueIndex:Number = 0;

var siID:Number = setInterval(checkPlayhead, 100);

function checkPlayhead() {
var myCueData:Object = cueData[cueIndex];
var currentTime:Number = myFLVPlaybackComponent.playheadTime;
if (currentTime >= myCueData.cue_time) {
cueIndex ++;
if (cueIndex >= cueData.length) {
clearInterval(siId);
}
}
}




SMB
9/28/2006 1:08:26 PM

[quoted text, click to view]

Whoops... I guess this shows how long it has been for me. I don't remember
FLVPlayback having cuePoints as part of its class... but anyway. In the
help docs it shows them using a listener for the event of a cuePoint (this
makes a lot more sense) to have the FLVPlayback broadcast hitting a cuePoint
rather than having some other function checking.

So, from the docs it would be more like (again not tested)

** assumes your movie clip instance is named my_movie and your FLVPlayback
is my_video.

my_movie.my_video.addASCuePoint(12.0, "frame 2");
my_movie.my_video.addASCuePoint(24.0, "frame 3");
// Now you have cue points that the FLVPlayback knows about, and when it
gets to the cuePoint time it will fire off the cuePoint event... so

var listerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
use eventObject here...
}
my_movie.my_video.addEventListener("cuePoint", listenerObject);

SMB
9/28/2006 1:23:16 PM

[quoted text, click to view]

I think the name and time need to be reversed in the addCuePoint calls.

Licarell
9/28/2006 7:11:10 PM
Here is my situation. I have an flv with two event cue points. I have placed a
FLVPlayback into my movie and called the instance "my_video".

All I want to do is have my "begin" cue point tell my movie to gotoAndStop at
frame 18 and then the second cue point "white flash" to tell the movie to
gotoAndPlay at frame 19.

Thats it...I've poured over the help files and all over the forums and I still
can't seem to get my head wraped around this.

I'm usually pretty good at picking this stuff up but now I'm so frustrated and
I can't think straight.

Please help!!
LuigiL
9/28/2006 8:20:25 PM
Try attached code.



//use an object to listen for events
var myDisplayListener:Object=new Object();
//add event cuePoint to the object
myDisplayListener.cuePoint=function(eventObj:Object){
var index=eventObj.target.name;
if(index=="begin"){
_level0.gotoAndStop(18);
}
if(index=="white flash"){
_level0.gotoAndPlay(19);
}
}
//set up the listener
my_video.addEventListener("cuePoint",myDisplayListener);
//add a cuepoint
my_video.addCuePoint("begin",0);//set correct duration in seconds for 0
my_video.addCuePoint("white flash",30);//set correct duration in seconds for 30
AddThis Social Bookmark Button