Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Javascript to randomly load flash .swf

Reply
Thread Tools

Javascript to randomly load flash .swf

 
 
Jess
Guest
Posts: n/a
 
      03-17-2005
I have tried all of the solutions given by other members on how to load
a random .swf file on the load of the page, however, none of them seem
to work on my site. The problem is in embedding the random .swf in the
object tag of my code. Could someone please shed some light on this
issue for me because I'm clueless on this one?

 
Reply With Quote
 
 
 
 
otto
Guest
Posts: n/a
 
      03-17-2005
Probably not the answer you want to hear in a JavaScript forum, but why
don't you try loading a Flash movie that loads other Flash movies into
itself randomly using ActionScript?

 
Reply With Quote
 
 
 
 
Jess
Guest
Posts: n/a
 
      03-17-2005
How do you use ActionScript to do this?

 
Reply With Quote
 
otto
Guest
Posts: n/a
 
      03-17-2005
This is really quick and dirty, but try this:

Name all of your swfs with the same name plus a number. (ex.
movie1.swf, movie2.swf, movie3.swf, etc.)

Create another movie with one frame. Put this actionscript in the
frame:

var basename = "movie";
var totalmovies = 3;
var movietoload = basename +
Math.ceil((Math.random()*totalmovies))+".swf";
_root.loadMovie(movietoload);

Set basename equal to the basename of the swf files you're going to
load (in this example "movie") and set totalmovies equal to the number
of movies you have that can be loaded randomly.

That should do the trick and since it relies on the Flash player rather
than the browser, it'll be more cross-browser compatible.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Javascript function upon Page Load from Page Load event handle Matcon ASP .Net 3 05-28-2008 05:15 PM
System hangs randomly during OS (XP x64) load nickade@gmail.com Windows 64bit 16 12-11-2006 07:19 PM
How to use javascript to pull randomly from an XML file TPK Javascript 2 10-03-2006 02:20 PM
dynamic load javascript from javascript howachen@gmail.com Javascript 0 02-08-2006 04:01 PM
WIFI connection randomly/non randomly disconnects King Fu Wireless Networking 2 11-10-2004 07:03 AM



Advertisments