Skip to main content
Known Participant
November 10, 2006
Question

Random FlV

  • November 10, 2006
  • 1 reply
  • 125 views
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.
This topic has been closed for replies.

1 reply

Inspiring
November 12, 2006
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.