Making Video Stop from when loading from XML

I currently have the following banner running that uses XML to run through a cycle of videos/with headlines
Using the existing code pasted below, can anyone tell me how to have it choose one video at random  then stop after playing one video, instead of moving on to the next one, like it currently does

____________________________________________________________
var videoPlaylist_xml:XML = new XML();
var videoPlaylist_arr:Array = new Array();
var index = 0;
var clickTAG = "";
videoPlaylist_xml.ignoreWhite = true;
videoPlaylist_xml.onLoad = function()
{
      var videos_array:Array = this.firstChild.childNodes;
      for (var i:Number = 0; i < videos_array.length; i++)
      {
            videoPlaylist_arr.push({Description:videos_array[i].attributes.description, File:videos_array[i].attributes.file, Link:videos_array[i].attributes.link});
      }
      trace(mx.data.binding.ObjectDumper.toString(videoPlaylist_arr));
      playVideo(index++);
};
videoPlaylist_xml.load("videos.xml");
//
playVideo = function (i)
{
      clickTAG = videoPlaylist_arr[i].Link;
      description_txt.text = videoPlaylist_arr[i].Description;
      my_FLVPlybk.contentPath = videoPlaylist_arr[i].File;
      my_FLVPlybk.play();
     
};
//
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void
{
      if (index < videoPlaylist_arr.length - 1)
      {
            playVideo(index++);
      }
};
my_FLVPlybk.addEventListener("complete", listenerObject);var videoPlaylist_xml:XML = new XML();
var videoPlaylist_arr:Array = new Array();
var index = 0;
var clickTAG = "";
var playlistOrder = new Array();
videoPlaylist_xml.ignoreWhite = true;
videoPlaylist_xml.onLoad = function()
{
      var videos_array:Array = this.firstChild.childNodes;
      for (var i:Number = 0; i < videos_array.length; i++)
      {
            videoPlaylist_arr.push({Description:videos_array[i].attributes.description, File:videos_array[i].attributes.file, Link:videos_array[i].attributes.link});
            totalNum = i;
      }
      for(i = 0; i <= totalNum; i++) {
            number = 1;
            bad = true;
            while(bad) {
                  number = Math.round(Math.random()*totalNum);
                  tempbad = false;
                  for(j in playlistOrder) {
                        if(playlistOrder[j] == number) {
                              tempbad = true;
                        }
                  }
                  bad = tempbad;
            }
            playlistOrder[i] = number;
      }
      //trace(mx.data.binding.ObjectDumper.toString(videoPlaylist_arr));
      playVideo(index++);
};
videoPlaylist_xml.load("videos.xml");
//
playVideo = function (num)
{
      i = playlistOrder[num];
      trace(i);
      clickTAG = videoPlaylist_arr[i].Link;
      description_txt.text = videoPlaylist_arr[i].Description;
      my_FLVPlybk.contentPath = videoPlaylist_arr[i].File;
      my_FLVPlybk.play();
     
};


moralecAsked:
Who is Participating?
 
ZvonkoConnect With a Mentor Systems architectCommented:
Check this:





var videoPlaylist_xml:XML = new XML();
var videoPlaylist_arr:Array = new Array();
var index = 0;
var clickTAG = "";
videoPlaylist_xml.ignoreWhite = true;
videoPlaylist_xml.onLoad = function(){
      var videos_array:Array = this.firstChild.childNodes;
      var i:Number = Math.floor(Math.random()*videos_array.length);
      clickTAG = videos_array[i].attributes.link;
      description_txt.text = videos_array[i].attributes.description;
      my_FLVPlybk.contentPath = videos_array[i].attributes.file;
      my_FLVPlybk.play();
};
videoPlaylist_xml.load("videos.xml");
//





0
 
ZvonkoSystems architectCommented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.