actionscript 3 - Timer flash to show something at the right time -


i want make timer show text @ paneltext (dynamic text box) @ specific time, have video want have subtitles, , want use timer, video 3 minutes , 37 second long, , have script want show @ time, example @ 1 minute 0 seconds show text "hello, video learn solar system" in paneltext, , @ 2 minute want show text "there 8 planets in our solar system", that. information, i'm using flvplayback play video , load external video.

an example code:

var mytimer:timer = new timer(217000); var time = 0; mytimer.start() mytimer.addeventlistener(timerevent.timer,timerhandle);  function timerhandle(event:timerevent){     if(mytimer == 120000)     {         paneltext.text="there's 8 planets in our solar system";     }                                                                               

and got error 1176: comparison between value static type flash.utils:timer , possibly unrelated type int. can me?, i'm sorry bad english

you should use flvplayback's addascuepoint() function make precise actions when flvplayback fideo playing. use function set whatever points want display custom subtitles, there can many of these want, listen metadataevent.cue_point event on flvplayback instance, , process cue point in order display associated subtitle. note though, have separately parse subtitle expiration, or assign cue point remove displayed subtitle several seconds past displaying cue point. although better if able add subtitles directly on video, seeking through video not require handling of misaligned subtitles. still, it's doable pure as3 code, if listen videoevent.fast_forward , videoevent.rewind events handle user interaction playback , display corresponding subtitle calling findnearestcuepoint() find closest earlier subtitle-enabled cue point.

an example of adding cue point:

flv.addascuepoint(0.1,"1",{text:"subtitle one"}); flv.addascuepoint(6.8,"2",{text:"subtitle two"}); flv.addascuepoint(11.8,"2 hide",{text:""}); // remove old subtitle flv.addascuepoint(120.0,"3",{text:"there 8 planets in our solar system"}); 

note each call returns object, returned whenever metadataevent.cue_point event dispatched. has parameters sub-object have passed addascuepoint third parameter, parse , take actions depending on what's in there. here, i've placed single field "text" each of parameter objects, should text display subtitles. so, listen cue point event , take actions, this:

flv.addeventlistener(metadataevent.cue_point,cuehandler);  // once, listener not need added per cue point function cuehandler(e:metadataevent):void {     var cuepoint:object=e.info;     if (cuepoint.parameters) {         paneltext.text=cuepoint.parameters.text;     } else {         // debug here     } } 

in case of seeking, listen ff , rewind events function call findnearestcuepoint(), retrieve parameters.text , place text text field.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -