# \<b\>xml controls in flash 9 actionscript 3\</b\>

**URL:** https://forum.kirupa.com/t/b-xml-controls-in-flash-9-actionscript-3-b/250124
**Category:** flash
**Created:** [January 25, 2008, 8:19pm UTC](https://forum.kirupa.com/t/b-xml-controls-in-flash-9-actionscript-3-b/250124 "2008-01-25T20:19:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kai\_asika](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kai\_asika](https://forum.kirupa.com/u/kai_asika)
#### Post date: [January 25, 2008, 8:19pm UTC](https://forum.kirupa.com/t/b-xml-controls-in-flash-9-actionscript-3-b/250124/1 "2008-01-25T20:19:03Z")

</div>

I’ve created an xml based play list but I’m having trouble adding an XML based navigation bar, IN FLASH AS3, that will take me to specific sections in the main xml file.

actionscript \>\> main xml script area:  
[COLOR=RoyalBlue]//////////////////////////////////////////////////////////////////////////////flv player promgraming

import fl.video._; // \*\* enables flv play  
import fl.events.ScrollEvent; // enables dynamic scroll field_\*\*\*

// set up all of our Array’s for the XML data to be loaded later…  
var flvControl = vid\_mc.myVid;  
var videoList:Array = [];  
var vidSectionList:Array =[];  
var clientList:Array = [];  
var campaignList:Array = [];  
var outOfList:Array = [];  
var titleList:Array = [];  
var dateList:Array = [];  
//var thumbList:Array = [];  
//var urlList:Array = [];  
var mediaList:Array = [];  
var clientLabelList:Array = [];

var videoIndex:Number = 0; //start number for the video to play (essentially this is the track Number)  
var b:Number = 0; //for use in the while loop below.  
var clientVar:String = “Loading…”; // eventually holds the artist name in front of video  
var campaignVar:String = “Loading…”;// eventually holds the campaign name underneath the video  
var outOfVar:String = “Loading…”;// eventuall loads the ‘out of’ text in dynamic txt box  
var mediaVar:String = “Loading…”;//dynamic text box for the media list  
var clientLabelVar:String = “Loading…”;

// XML data loader…  
var xmlURLLoader:URLLoader = new URLLoader();  
var xmlURLRequest:URLRequest = new URLRequest(“xml/\_dl\_videos.xml”); //relative location of .xml file. In this case, it must reside where the .swf is  
xmlURLLoader.load(xmlURLRequest);  
xmlURLLoader.addEventListener(Event.COMPLETE , dataLoaded );

function dataLoaded(event:Event):void {  
var theXMLData:XML = new XML (xmlURLLoader.data);  
var a:Number = theXMLData.video\_path.length();

```
while (b &lt; a){
	videoList.push( theXMLData.video_path** ) ; //adds the XML data to the appropriately named Arrary
	mediaList.push( theXMLData.media_label** );
	clientLabelList.push( theXMLData.clientLabel_name** );
	clientList.push( theXMLData.client_name** );
	campaignList.push( theXMLData.campaign_title** );
	outOfList.push( theXMLData.number_outOf** );
	titleList.push( theXMLData.video_title** );
	dateList.push( theXMLData.video_date** );
	//thumbList.push( theXMLData.thumb_path** );
	//urlList.push( theXMLData.url_link** );

```

with(holder){ // while loop populates the “holder” movieclip with runtime-added instances of the movieclip “vid\_details” (linkage ID) from the Library

```
		var vidTemplate:MovieClip = new vid_details();
		vidTemplate.x = 0;
		vidTemplate.y = b * 50 ; // positions them in a column
		vidTemplate.artistBox.text = clientList**; // fills in the text box in each MovieClip with data from the array
		//idTemplate.campaignBox.text = campaignList**;
		vidTemplate.titleBox.text = titleList**;
		vidTemplate.dateBox.text = dateList**;
		
		vidTemplate.trackNum = b; // gives each Movieclip a kind of id, essentially the current Track Number if clicked
		//vidTemplate.urlVar = urlList**;
		//vidTemplate.thumbPathVar = thumbList**;
		vidTemplate.flvPathVar = videoList**;
	
		addChild(vidTemplate); //finally adds the Child to the "holder" instance
		}
		
	b = b + 1;
	}

flvControl.autoPlay = true; 
flvControl.source = videoList[videoIndex]; // assigns the flvControl the first FLV path to load
clientVar = clientList[videoIndex];
campaignVar = campaignList[videoIndex];
outOfVar = outOfList[videoIndex];
mediaVar = mediaList[videoIndex];
clientLabelVar = clientLabelList[videoIndex];

```

myScroller.source = holder; //\*\* important\*\* this attaches the scroller to the holder movieclip (the thing with all the video buttons)

}

flvControl.volume = .5; // sets the volume at 50%

// code sets up buttons for controlling the FLVPlayback component

flvControl.playPauseButton = all\_buttons.PlayPauseBtn;  
flvControl.backButton = all\_buttons.BackBtn;  
flvControl.forwardButton = all\_buttons.ForwardBtn;  
flvControl.seekBar = all\_buttons.SeekBarBtn;  
flvControl.muteButton = all\_buttons.MuteBtn;

/\* code for the BackBtn instance onstage to go to the next video,  
note that you can put ANY other code in that function as well \*/

all\_buttons.BackBtn.addEventListener(MouseEvent.CL ICK, backClick);

function backClick(event:MouseEvent):void {  
videoIndex = videoIndex - 1;

```
if (videoIndex == -1) {
	videoIndex = videoList.length - 1;

}
flvControl.source = videoList[videoIndex];
clientVar = clientList[videoIndex];
campaignVar = campaignList[videoIndex];
outOfVar = outOfList[videoIndex];
mediaVar = mediaList[videoIndex];
clientLabelVar = clientLabelList[videoIndex];

```

}  
/\* code for the ForwardBtn instance onstage to go to the next video,  
note that you can put ANY other code in that function as well \*/

all\_buttons.ForwardBtn.addEventListener(MouseEvent .CLICK, forwardClick);

function forwardClick(event:Event):void {

```
videoIndex = videoIndex + 1;

if (videoIndex == videoList.length) {
	videoIndex = 0;
}
flvControl.source = videoList[videoIndex];
clientVar = clientList[videoIndex];
campaignVar = campaignList[videoIndex];
outOfVar = outOfList[videoIndex];
mediaVar = mediaList[videoIndex];
clientLabelVar = clientLabelList[videoIndex];

```

}

// when the video ends it goes to the next video in the playlist…

flvControl.addEventListener( VideoEvent.COMPLETE, nextMovie );

function nextMovie(event:Event):void {

```
if (flvControl.scrubbing == false) {

	videoIndex = videoIndex + 1;

	if (videoIndex == videoList.length) {
		videoIndex = 0;
	}
	flvControl.source = videoList[videoIndex];
	clientVar = clientList[videoIndex];
	campaignVar = campaignList[videoIndex];
	outOfVar = outOfList[videoIndex];
	mediaVar = mediaList[videoIndex];
	clientLabelVar = clientLabelList[videoIndex];
	
}

```

}

// code for positioning everything based on the x and y location of vid\_mc (and width and height of the FLV Component inside it)

myScroller.setSize ( 257 , vid\_mc.height - 2 );

[/COLOR]

//all\_buttons.bottomBar.width = vid\_mc.width + myScroller.width;

// event listener for changing the time display, and current track number display, and current Artist playing

this.addEventListener (Event.ENTER\_FRAME, updateNP);

function updateNP(event:Event):void {  
[//statusBox.text](https://statusBox.text) = "Track " + (videoIndex + 1) + " of " + videoList.length ;  
artistBox.text = clientVar;  
campaignBox.text = campaignVar;  
outOfBox.text = outOfVar;  
mediaBox.text = mediaVar;  
clientLabelBox.text = clientLabelVar;

```
// time code code...
var totalSeconds:Number = flvControl.playheadTime;
var totalSeconds2:Number = flvControl.totalTime;
var minutes:Number = Math.floor(totalSeconds /60);
var minutes2:Number = Math.floor(totalSeconds2 /60);
var seconds = Math.floor (totalSeconds) % 60;
var seconds2 = Math.floor (totalSeconds2) % 60;
if (seconds &lt; 10){
	seconds = "0" + seconds;
}
if (seconds2 &lt; 10){
	seconds2 = "0" + seconds2;
}
timeBox.text = minutes + ":" + seconds + " / " + minutes2 + ":" + seconds2;

```

}

xml sample:  
[COLOR=RoyalBlue]\<videos\>  
\<vidSection NAME=“TV”\>  
\<video\_path\>ASSETS/DALLAS/TV/BMW/daltv\_bmw\_hampster.flv\</video\_path\>  
\<media\_label\>TV\</media\_label\>  
\<clientLabel\_name\>My Client\</clientLabel\_name\>  
\<client\_name\>BMW\</client\_name\>  
\<campaign\_title\>HAMPSTER\</campaign\_title\>  
\<number\_outOf\>1 of 1\</number\_outOf\>  
\<video\_title\>2007 reel\</video\_title\>  
\<video\_date\>2007\</video\_date\>  
\<thumb\_path\>thumbs/mwaiReel07.jpg\</thumb\_path\>  
\<url\_link\>\</url\_link\>  
\</vidSection\>  
\</videos\>[/COLOR]
