using random files

  • 1
  • Question
  • Updated 9 years ago
  • Answered
is there any way to get a flash player to play a random swf file from a single folder? for example any random file in my folder resources/swf/.
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
  • always happy

Posted 9 years ago

  • 1
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
14 hours later no reply, i'll take that as a no. :)
Lee.
Photo of Peter

Peter

  • 2569 Posts
  • 113 Reply Likes
Hi Lee,

Good news. It has been reported as being done done successfully.

The outline is that you name your movies with a name and a sequential number. eg: movie1.swf, movie2.swf,....... movie(n).swf

Generate a random number between 1 and the number of movies (n) stored. Then concatenate that generated number with the prefix name. This part of the process works well. The randomness seems to be valid.

In your playing code the name of the movie is the generated concatenated name.

Reference:
http://www.dynamicdrive.com/forums/sh...
#2 in the thread.
Photo of Emmy

Emmy

  • 5892 Posts
  • 299 Reply Likes
Thanks Peter! Lee, let us know if you have any luck with this.
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
Thanks Peter, im playing with it now (on a test page) what im hopeing to do is play random flash adverts in certain areas of my site. i dont want to have to change them all the time, this looks good, thanks again. Lee.
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
i tried to get that code working but failed, i have used a different one (the code form the site the guy in the other forum made) and i managed to get 2 files playing randomly, see the bottom advert on my home page http://hexham.info if you refresh the page it should have a different background, this is a totally differnet file. :)

<!--
<p align="justify">
<script language="JavaScript">

// Generate a Random Number
var randomnumber = Math.round(Math.random()*2);

// Select a movie and execute the corresponding function
if (randomnumber == 1)

{movie1();}

else {movie2();}

//Functions to write out the correct flash movie resource.

function movie1(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/sh..." width=\"160\" height=\"600\"><param name=movie value=\"resources/test1.swf\"><param name=quality value=high><embed src=\"resources/test1.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/d..." type=\"application/x-shockwave-flash\" width=\"160\" height=\"600\"></embed></object>")
}

function movie2(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/sh..." width=\"160\" height=\"600\"><param name=movie value=\"resources/test2.swf\"><param name=quality value=high><embed src=\"resources/test2.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/d..." type=\"application/x-shockwave-flash\" width=\"160\" height=\"600\"></embed></object>")
}

</script>
-->

i want to have at least 10 playing randomly - any help would be much appreciated
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
how about image files, can this be done with images?
Photo of Peter

Peter

  • 2569 Posts
  • 113 Reply Likes
Hi Alex, The thought that comes to mind is to create a number of flash slide shows. Number each show in a sequence. The slide shows are flash movies so then it becomes identical.
I think there would be other options as well.
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
well Lee you have A BIG problem, take a look at this image.
yea, you have no links on your homepage. Only A is there.

al
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
thanks Alex, i am playing with them - i pressed publish instaed of preview. Lee.
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
Hi Everyone! i need to do this with HTMl, i am currently advertiseing amazon on my site, the ad are flash, but they are html codes how do i make them appear randomly?