Randomly Load External VDO w/o Repeat the Same File while Playing
Hey! I have nearly done programming my Flash file. But, I'm so tired of making it not repeat the VDO file it is playing.
I hope that you guys will have that solution for me. *()*
This is my source code
////////////To Load any VDO///////////////
import flash.net.NetStream;
import flash.net.NetConnection;
import flash.media.Video;
var video;
var nc;
var ns;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.client = this;
video = new Video(550,400);
addChild(video);
video.attachNetStream(ns);
///////////////////////////
/////////////Array for VDO Files/////////////
var VdoStore:Array = new Array("westler.flv","TomAndJerry.flv","GetThere.flv");
///////////////////////////
/////////////Keyboard and Screen Show////////////////
import flash.events.KeyboardEvent;
import flash.events.Event;
stage.addEventListener(KeyboardEvent.KEY_DOWN,onDown);
stage.addEventListener(KeyboardEvent.KEY_UP,onUP);
function onDown(e:KeyboardEvent):void{
var SelectedVid = VdoStore[Math.floor(Math.random() * VdoStore.length)];
//var DontRepeat:Array = new Array(); << I tried create another array to keep the file which was played
if (e.keyCode==49)
{
ns.play(SelectedVid);
stage.removeEventListener(KeyboardEvent.KEY_DOWN,onDown);
//onUP(null);
}
if (e.keyCode==69)
{
ns.play(SelectedVid);
stage.removeEventListener(KeyboardEvent.KEY_DOWN,onDown);
//onUP(null);
}
}
function onUP(e:KeyboardEvent):void
{
if(e.keyCode==49)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN,onDown);
}
if(e.keyCode==69)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN,onDown);
}
}
And thst is the code that I have removed all the things I have experimented out. Only the code that is working is shown above.
I don't need them all to be played before start new random. Just That, it shouldn't play the same vdo that is playing at the moment when I click any button after.
FYI,I will add more vdos, about 20, and more keyboard buttons to click as the same numbers.
Anyone? **Pleaseeeeeeee >///<