Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Randomly Load External VDO w/o Repeat the Same File while Playing

New Here ,
Nov 27, 2013 Nov 27, 2013

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 >///<

TOPICS
ActionScript
381
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 27, 2013 Nov 27, 2013

One way would be to remove the played video from the array when it is played so that it cannot be licked again.

Another way, since you don't mind a repeat later on, would be to store the index of the selected video when it is played in a variable that you compare to the selected index.  If the selection matches the variable then you run the selection processing again until you successfully pick another video.  To do this it will be easier to have a separate function that does the selection.

Translate
LEGEND ,
Nov 27, 2013 Nov 27, 2013
LATEST

One way would be to remove the played video from the array when it is played so that it cannot be licked again.

Another way, since you don't mind a repeat later on, would be to store the index of the selected video when it is played in a variable that you compare to the selected index.  If the selection matches the variable then you run the selection processing again until you successfully pick another video.  To do this it will be easier to have a separate function that does the selection.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines