# Loading Videos & Text From XML

**URL:** <https://forum.kirupa.com/t/loading-videos-text-from-xml/200416>\
**Category:** flash\
**Created:** [September 12, 2006, 2:43am UTC](https://forum.kirupa.com/t/loading-videos-text-from-xml/200416 "2006-09-12T02:43:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xposed](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/xposed/32/1641_2.png) [@xposed](https://forum.kirupa.com/u/xposed)\
**Post date:** [September 12, 2006, 2:43am UTC](https://forum.kirupa.com/t/loading-videos-text-from-xml/200416/1 "2006-09-12T02:43:00Z")

</div>

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](https://list.rowHeight) = 70;  
[//list.cellRenderer](https://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&lt;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](https://video.clear)();  
}  
stop();
