flash animation video tutorials

 

 

 

 

 

START LEARNING
FLASH NOW

Get instant access to over
45 minutes of FREE Flash tutorials on video
 and our newsletter.

Name:
E-Mail:

.

.

.

 
Web video-animation.com

.

.

flash tutorials flash tutorials flash tutorials flash tutorials

xml playlist for Flash 8 flv video player

This tutorial follows on from the last tutorial about creating a simple flv player using NetConnnection and NetStream objects that are used in Flash Media Server actionscript programming. This tutorial was taken from the excellent video tutorials by Lee Brimelow at GotoandLearn.com . Ok. Let us start then. The first thing to do is create a number of .flv video files and put them in the same folder as the flash and .xml files we will create. I created four .flv videos. tkd01.flv - tkd04.flv.
The Next thing to do is write your XML file which will hold the names of your videos and a description.
Why use an xml file for your playlist I hear you say?
Well you can easily change the xml text file and leave the .swf alone and you wont have to touch the .fla anymore if you want to change the videos.

Flash Tutorials in Video Format - Watch them now at LearnFlash.com  

Open up a text editor and write your xml file. Call it videos.xml.
You can use the full url if you like. e.g. http://www.site.com/videos/surf01.flv
Desc is the description that will come up in our listbox.


<?xml version="1.0" encoding="ISO-8859-1" ?>
<videos>
<video url="tkd01.flv" desc="Girls paddling out" />
<video url="tkd02.flv" desc="Girls surfing" />
<video url="tkd03.flv" desc="Surfest Contest" />
<video url="tkd04.flv" desc="Tae Kwan Do" />
</videos>

Use the last fla that we did in the last tutorial.
Create a new layer and put a listbox component next to our video player.
Make it the size you want. I made mine 245x240.
Give it the instance name of videoList.
Write this code in the Actionscript window after the other code already in there.
This code creates an XML object and loads the xml nodes into an array.
Then it puts the array into the listbox.
The NetStream object reads the listbox item that is selected and plays it.


// xml playlist
// create an XMl object
var vidList:XML = new XML();
// ignore white spaces
vidList.ignoreWhite = true;
vidList.onLoad = function() {
// put the nodes of xml into array
var videoArray:Array = this.firstChild.childNodes;
// iterate through video array
// and add videos to the listbox
for (var i = 0; i<videoArray.length; i++) {
videoList.addItem(videoArray[i].attributes.desc, videoArray[i].attributes.url);
}
// when xml is loaded play first item
ns.play(videoList.getItemAt(0).data);
// highlight first video in listbox
videoList.selectedIndex = 0;
};
// create a listener that responds 
// to changes in the listbox
var vidListener:Object = new Object();
vidListener.change = function() {
// play the item selected in listbox
ns.play(videoList.getItemAt(videoList.selectedIndex).data);
};
// register the event listener to listbox
videoList.addEventListener("change", vidListener);
// load xml file
vidList.load("videos.xml");

Flash 8 Resources

flv video player - go back to do the first part of this tutorial to create the flv player.

.

flash 8