The first line of the code brings in the video package because we will need its methods and properties to control the component. The next three lines set the autoplay and contentPath values that would otherwise be used in the Parameters panel. The final line simply resets the video back to the start when it finishes.
An array is then created to hold the captions. With the housekeeping out of the way I create a new XML object to hold the XML and tell the object to ignore any white space in the XML document that will be used by the XML object.
The onLoad method is used to bring the XML document into Flash and the variable – captions – is set to be equal to the number of child nodes in the XML doc. The for loop uses the length of the caption array to set how many times the loop itterates. From there the times and the captions are pulled out of the XML document.
At the same time a number of cue points, equal to the number of items in the list is created and the values in the XML document are used at the parameters for the cue point.
The next two lines simply load the XML document and add an eventListener that tells Flash what to listen for which, surprise,surprise is a cue point. The last function tells Flash that every time a cue point is encountered to stick the text associated with the cue point in the text box.