troubleshooting Question

Making Video Stop from when loading from XML

Avatar of moralec
moralec asked on
XMLAdobe Flash
2 Comments1 Solution187 ViewsLast Modified:
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();
     
};


ASKER CERTIFIED SOLUTION
Zvonko
Systems architect
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros