# Flv playback - cant make it play randomly

**URL:** <https://forum.kirupa.com/t/flv-playback-cant-make-it-play-randomly/330624>\
**Category:** Uncategorized\
**Created:** [February 19, 2013, 5:14pm UTC](https://forum.kirupa.com/t/flv-playback-cant-make-it-play-randomly/330624 "2013-02-19T17:14:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![magie](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@magie](https://forum.kirupa.com/u/magie)\
**Post date:** [February 19, 2013, 5:14pm UTC](https://forum.kirupa.com/t/flv-playback-cant-make-it-play-randomly/330624/1 "2013-02-19T17:14:37Z")

</div>

hello,  
im working on a [project](http://www.pos-creation.com/wu/xml_video_playlist.html)that needs my immediate attention but i can t seem to make it work, since im not very good with scripting… What i need to do here, is to make the 3 flvs which play when the lists buttons are pressed, to play randomly and get rid of the playlist. The second part i know how to do, the random play is the problem. Please help ![](http://forum.kirupa.com/uploads/kirupa/798/c985a958819d8917.gif) thanks in advance

this is the as im using  
\*  
var nc:NetConnection = new NetConnection();  
nc.connect(null);

var ns:NetStream = new NetStream(nc);

theVideo.attachVideo(ns);

ns.setBufferTime(10);

this.createEmptyMovieClip(“vFrame”,this.getNextHig hestDepth());  
vFrame.onEnterFrame = videoStatus;

var amountLoaded:Number;  
var duration:Number;

ns[“onMetaData”] = function(obj) {  
duration = obj.duration;  
}

function videoStatus() {  
amountLoaded = ns.bytesLoaded / ns.bytesTotal;  
loader.loadbar.\_width = amountLoaded \* 208.9;  
loader.scrub.\_x = ns.time / duration \* 208.9;  
}

var scrubInterval;

loader.scrub.onPress = function() {  
vFrame.onEnterFrame = scrubit;  
this.startDrag(false,0,this.\_y,208,this.\_y);  
}

loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {  
vFrame.onEnterFrame = videoStatus;  
this.stopDrag();  
}

function scrubit() {  
ns.seek(Math.floor((loader.scrub.\_x/208)\*duration));  
}

\_root.createEmptyMovieClip(“vSound”,\_root.getNextH ighestDepth());  
vSound.attachAudio(ns);

var so:Sound = new Sound(vSound);

so.setVolume(0);

mute.onRollOver = function() {  
if(so.getVolume()== 0) {  
this.gotoAndStop(“onOver”);  
}  
else {  
this.gotoAndStop(“muteOver”);  
}  
}

mute.onRollOut = function() {  
if(so.getVolume()== 100) {  
this.gotoAndStop(“on”);  
}  
else {  
this.gotoAndStop(“mute”);  
}  
}

mute.onRelease = function() {  
if(so.getVolume()== 100) {  
so.setVolume(0);  
this.gotoAndStop(“muteOver”);  
}  
else {  
so.setVolume(100);  
this.gotoAndStop(“onOver”);  
}  
}

var vlist:XML = new XML();  
vlist.ignoreWhite = true;

vlist.onLoad = function() {  
var videos:Array = this.firstChild.childNodes;  
for(i=0;i\<videos.length;i++) {  
videoList.addItem(videos\*.attributes.desc,videos\*.attributes.url);  
}

```
ns.play(videoList.getItemAt(0).data);
videoList.selectedIndex = 0;

```

}

var vidList:Object = new Object();

vidList.change = function() {  
ns.play(videoList.getItemAt(videoList.selectedInde x).data);  
}

videoList.addEventListener(“change”,vidList);

vlist.load(“videos.xml”);

videoList.setStyle(“selectionColor”,0xFFFF00);  
videoList.setStyle(“textSelectedColor”,0x000000);  
videoList.setStyle(“rollOverColor”,0xCCCCCC);\*
