Listed below is code that pulls videos from an XML file. How can I add code to it so that when I click a certain area in the list box that is populated with the videos from the XML file, so that it also loads textbox in to a text on the screen?
My textbox has an instance name of ‘textBox’
I’m not sure If i would have to edit the XML file as well?
<listitem name=“Verse Slowed Down” stream=“5” />
There is an example xml entry, part of me thinks I would have to add a text="" value?
import XMLHelper;
var playList:String = “playlist.xml”;
//Set up the list box, call function VideoThumb to create the actual thumbnails
//list.rowHeight = 70;
//list.cellRenderer = “VideoThumb”;
list.selectable = true;
stop_pb.enabled = false;
nc = new NetConnection();
nc.connect( null );
// create a new instance of XMLManager
xmlHelper = new XMLHelper();
var xmlListener = new Object();
xmlListener.mc = this;
xmlListener.onloaded = function(p_event:Object)
{
var children = p_event.xml.firstChild.childNodes;
var streamlist = []; // this is our list’s dataprovider
for (var i = 0; i<children.length; i++)
{
//trace(children*.attributes.name);
//trace(children*.attributes.stream);
// display the 'name' attribute and hold the 'stream' attribute as data
streamlist* = {label: children*.attributes.name, data: children*.attributes.stream};
}
ns = new NetStream(nc);
ns.onStatus = function(info){
//trace(info.code);
}
video.attachVideo(ns);
list.dataProvider = streamlist;
var flvfile = list.getItemAt(0).data + ".flv";
ns.play(flvfile);
};
xmlListener.haserror = function(p_event:Object)
{
trace(“error loading XML”);
};
xmlHelper.load(playList);
xmlHelper.addEventListener(“onloaded”, xmlListener);
xmlHelper.addEventListener(“haserror”, xmlListener);
//create new empty listener object
listListener = {};
//Function to handle what happens when an item in the list is selected
listListener.change = function( evtobj )
{
// enable stop button
stop_pb.enabled = true;
// close any current stream
ns.close();
//create a new stream
ns = new NetStream(nc);
ns.onStatus = function(info){
//trace(info.code);
}
video.attachVideo(ns); //pipe stream to this video object
var flvfile = evtobj.target.selectedItem.data + ".flv";
// play it
ns.play( flvfile );
ns.onStatus = function(info) {
if (info.code == “NetStream.Play.Stop”) {
ns.seek(0);
}
};
}
//Add an event listener on the list
list.addEventListener(“change”, listListener);
//resizes the video object to the width and height of the clip
function onVideoResize() {
if ( video.width != video._width || video.height != video._height ) {
video._width = video.width;
video._height = video.height;
}
}
setInterval( onVideoResize, 200 ); //keeps checking video size
stop_pb.onRelease = function(){
ns.pause();
//video.clear();
}
stop();