Log in

View Full Version : Random movie clip on load



the penguin
03-13-2011, 12:43 AM
Hello, I have this code and file. It works, but I want just one movie clip to play randomly, not two, or three. Please help! :confused:


var clips:Array = ["redl_mc", "blue_mc", "green_mc"];
playRandomMC();
function playRandomMC() {
var index:Number = Math.floor(Math.random()*clips.length);
for (var i:Number = 0; i<clips.length; i++) {
var mc:MovieClip = _root[clips[i]];
if (i == index) {
mc._visible = true;
mc.play();
} else {
mc._visible = false;
mc.stop();
}
}
}

mat420
03-13-2011, 07:33 PM
What do you mean by randomly exactly? You dont want it to play as soon as the page loads? Are you picky about how the video plays and what options are available to the user that its playing to (stop pause mute)? What type of file is the video?