Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Randomly load FLV?

Status
Not open for further replies.

TigerGirl7

Programmer
Apr 8, 2003
152
US
Hi,

I'm using the following code to load an FLV into my flash movie. Does anyone know how to adjust the code to randomly load one of three FLVs? (video_1.flv, video_2.flv, video_3.flv)

Code:
var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);


theVideo.attachVideo(ns);

ns.play("video_1.flv")
 
Here's the solution!!!


var videos:Array = new Array("a.flv", "b.flv", "c.flv");

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
videoPlayer.attachVideo(ns);

var index:Number = Math.floor(Math.random() * videos.length));
ns.play(videos[index]);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top