1 Reply Latest reply on Nov 11, 2006 6:09 PM by injpix

    Random FlV

    german01 Level 1
      Hi:

      I'm trying to randomly load a set of 10 short videos. I have an instance of FLVplayback on the stage named my_video. Here is the script I used, which loads the first video randomly. However, after the first video finished, no other video is loaded.

      var VideoArray = new Array();
      VideoArray = ["Q1.flv", "Q2.flv", ......"Q10.flv"];

      var currentVideo =random(9);

      my_video.play(VideoArray[currentVideo]);

      var listenerObject:Object = new Object();
      listenerObject.complete = function(eventObject:Object):Void {
      VideoArray = random (9)
      };
      my_video.addEventListener("complete", listenerObject);

      QUESTIONS:

      1. How to randomly load FLV's?
      2. How to make the loaded videos not play automatically?

      Thanks for your help.


      German
      Please check my script and suggest ways to make it work.
        • 1. Re: Random FlV
          injpix Level 3
          To answer your first question, you would need to obviously replace this line of code of yours;
          var currentVideo =random(9);

          With perhaps the function that is posted in this webpage;
          http://www.quip.net/blog/2006/flash/choosing-random-numbers-redux

          And to answer your second question you would need to have this line of code;
          my_video.play(VideoArray[currentVideo]);

          …ideally inside a function. However you would still need an event (mouseclick, onLoad, time, to name just a few) of some kind to call that function.