Javascript to randomly load flash .swf

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jess

    Javascript to randomly load flash .swf

    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?

  • otto

    #2
    Re: Javascript to randomly load flash .swf

    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?

    Comment

    • Jess

      #3
      Re: Javascript to randomly load flash .swf

      How do you use ActionScript to do this?

      Comment

      • otto

        #4
        Re: Javascript to randomly load flash .swf

        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()*total movies))+".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.

        Comment

        Working...