Jump to content


Adding cuepoints at runtime via a loop

Recommended Posts

Hi there,


I'm trying to add cuepoints to a video at runtime to display subtitles. I'm using a loop to get my cuepoints from XML and add them using the addASCuePoint method. But for some reason only the first 2 cuepoints seem to be displaying.


Here is my for loop:


for (var i:int = 0; i < subtitlesXml.cuePoint.length(); i++)


    cuepointStart = subtitlesXml.cuePoint.attribute("substart");

    cuepointEnd = subtitlesXml.cuePoint.attribute("subend");

    subtitles = subtitlesXml.cuePoint.subtitle;


    videoLoader.addASCuePoint(cuepointStart, "substart " + i, {id:i});   

    videoLoader.addASCuePoint(cuepointEnd, "subend");


    trace(cuepointStart + " " + cuepointEnd + " " + subtitles);



and here is my cuepoint listener:


private function cuePointHandler(e:LoaderEvent):void



   if(e.data.name == "substart")


    subTextField.text = subtitles[e.data.parameters.id];


   else if(e.data.name == "subend")


    subTextField.text = "";


   else if(e.data.name == "break")






And here is my XML:




<cuePoint id="0" substart="7.0" subend="11.0">

  <subtitle><![CDATA[subtitle 1]></subtitle>



<cuePoint id="1" substart="16.0" subend="21.0">

  <subtitle><![CDATA[subtitle 2]]></subtitle>



<cuePoint id="2" substart="22:0" subend="24:0">

  <subtitle><![CDATA[subtitle 3]]></subtitle>



<cuePoint id="3" substart="26:0" subend="30:0">

  <subtitle><![CDATA[subtitle 4]]></subtitle>



<cuePoint id="4" substart="31:0" subend="35:0">

  <subtitle><![CDATA[subtitle 5]]></subtitle>



<cuePoint id="5" substart="36:0" subend="39:0">

  <subtitle><![CDATA[subtitle 6]]></subtitle>



Any help would be appreciated. 





Link to comment
Share on other sites

What a fool! Sorry for wasting anyones time who bothered to read this. Syntax error in my XML!

Link to comment
Share on other sites

Excellent. I was going to say that you're code looked solid. Thx for the update.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.