Random swf/f4v load
Hey I have this problem - with help from Kglad in a previous post plus a look on another post I have the underneath action script.
What I really need it to do, is to load a random movie from my array, and when it replay the movie it has to be the same movie as which was randomly loaded... So far I have this code:
var movies:Array =["film/film1.f4v", "film/film2.f4v"]
function shuffle(a:Array) {
for (var ivar = a.length-1; ivar>=0; ivar--) {
var p = Math.floor(Math.random())(ivar+1);
var t = a[ivar];
a[ivar] = a
;
a
= t;
}
};
var timedelay:Number = 10; // seconds delay in replay
var video;
var nc:NetConnection;
var ns:NetStream;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.client = this;
ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusf);
function netStatusf(e:NetStatusEvent) {
if (e.info.code == "NetStream.Play.Stop" && Math.abs(durationNum-ns.time)<.1) {
setTimeout(replayF,timedelay*1000);
}
}
function replayF(){
ns.play(shuffle(movies));
}
var durationNum:Number;
function onMetaData(iObj:Object):void {
durationNum = iObj.duration;
}
video = new Video(287,263);
video.x = 231.1;
video.y = 140.5;
addChild(video);
video.attachNetStream(ns);
ns.play(shuffle(movies));
but doesn't seem to work it comes with this error:
TypeError: Error #1006: value is not a function.
at cv/shuffle()
at cv/frame3()
at flash.display::MovieClip/gotoAndStop()
at cv/index()
Hope someone can help...