FORUMS: list search recent posts

Subtitles from XML cuepoints - some titles get skipped [AS3]

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Gord Stephen
Subtitles from XML cuepoints - some titles get skipped [AS3]
on May 31, 2009 at 7:56:29 pm

Hey there,

I'm working on a project that requires subtitles for Flash videos being streamed online. Right now I've got a player that will call up an XML file specific to the video being played, and from there will convert the contents of the XML file to cuepoints and display the titles, as set out in the XML file.

Problem is, I'd say at least 20% of the titles don't show up - the previous title stays up for too long and then the next title comes up eventually, and the one in the middle gets passed over. If I change the timing on the subtitles (i.e. push the problem title back by 0.5 seconds) then that title might show up but the one before or after it might disappear.

Has anyone run into this sort of thing before? I'll post the AS that I'm using to load the titles. The XML isn't standard cuepoint XML either. Code's based off of this tutorial, modified to play more than one video (different frames set different source .flv and .xml files and are connected by gotoAndStop() calls).

Is this even the best way of going about this all? Or should I be looking at embedding cuepoints directly into the video files (setting them in Premiere)? The footage is also going to be on DVD so ideally I could set up the titles in a format that Encore could import... as opposed to captioning everything twice.

this.mon_xml = new XML();

var request:URLRequest = new URLRequest("opening_sub.xml");
var loader:URLLoader = new URLLoader();


loader.addEventListener(Event.COMPLETE, SubTitlesLoaded, false, 0, true);

function SubTitlesLoaded(e:Event):void
var szXML:String = URLLoader(;
this.mon_xml = new XML(szXML);

function showSubtitle(
var current:Object = vidPlayer.findNearestCuePoint(vidPlayer.playheadTime);
this.txt_subtitles.text = current.parameters.texte;

function Launch():void
var list:XMLList = XMLList(this.mon_xml.cuepoints.cuepoint);
for (var i:Number = 0; i < list.length(); i++)
var _time:Number = Number(list[i].@time);
var _nom:String = list[i].@name;
var _texte:String = list[i].toString();
this.vidPlayer.addASCuePoint(_time, _nom, { texte:_texte } );

this.vidPlayer.addEventListener(, showSubtitle,false,0,true);;



Return to posts index

Le Merre Stéphane
Re: Subtitles from XML cuepoints - some titles get skipped [AS3]
on Jun 22, 2009 at 2:47:26 pm

Hello Gord,

I wrote this tutorial and noticed this bug on AS2 and AS3 (apologises for my poor english).
There are 2 ways to solve your problem, i do not recommend the first, because I do not exactly know what it change :

  • In VideoPlayer class, there is a constant :
    flvplayback_internal static const HTTP_DO_SEEK_INTERVAL:Number = 250;
    It permits to determine the minimum of the seeking state of the video; I not sure about what this interval is used for, but if works well if you set it to 25 instead of 250..

  • Second way : you can use a timer, something like :

    function timerHandler(evt:Event):void
    var current:Object = vidPlayer.findNearestCuePoint(vidPlayer.playheadTime);
    this.txt_subtitles.text = current.parameters.texte;

    and add this after the Launch function :

    var _timer:Timer = new Timer(250,0) ;
    _timer.addEventListener(TimerEvent.TIMER , timerHandler,false,0,true) ;
    _timer.start() ;

I hope this will help you,
Good luck

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved