Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Timelined Events To Play With FLV 1

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
Guys is there a way to force timelined events to play with an flv?

Say for instance I want to pull in a flv and while its playing at a certain point in the flash movie make something happen depending on the flv's playback?


Basically I'm trying to sync up timelined events as the flv plays.

Any Ideas?

Thanks,
Carl
 
After furthur research with the help of a forum member and macromedia live docs I found out that you can create cuePoints (certain sections of the movie by seconds played) for the flv and trigger events on the time line of the main movie with listeners.

Just in case anyone wanted the workaround:

Code:
[b]yourmediaplayer[/b].setMedia("test.flv");
[b]yourmediaplayer[/b].addCuePoint("point1", 12);
[b]yourmediaplayer[/b].addCuePoint("point2", 15);
[b]yourmediaplayer[/b].addCuePoint("point3", 21);
listenerObject = new Object();
listenerObject.cuePoint = function(eventObject) {
        evtObj = new Object();
        evtObj = eventObject.target;
        if (evtObj.name == "point1") {
                _root.[b]yourclip[/b].gotoAndPlay(2);
        }
        else if (evtObj.name == "point2"){
                _root..[b]yourclip[/b].gotoAndPlay(3);
        }
        else if (evtObj.name == "point3"){
                _root.[b]yourclip[/b].gotoAndPlay(4);
        }
};
test.addEventListener("cuePoint", listenerObject);

I do have one question for anyone who's interested though. Is there a better way to check for multiple cuepoints instead of using all of the else if statements? Total there will be about 18 events triggered from the flv.

18 esle if statements...Is there a better way?

Thanks,
Carl

----------------------------------------
 
One way to shorten the "else...if" stuff is using a switch. You still have 18 of them, but you don't have to loop through every single one every time. It would look like

Code:
switch (evtObj.name){
    case "point1":
        _root.yourclip.gotoAndPlay(2);
    break;
    case "point2":
        _root.yourclip.gotoAndPlay(3);
    break;
    case "point3":
        _root.yourclip.gotoAndPlay(4);
    break;
}

The distinct advantage of this is that it will only ever select the one single option that matches what's in the variable, as opposed to the "else...if" statements, where it will start from the top when look through every option until it finds one that matches. Should save you a few processing cycles.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top