Javascript to randomly load flash .swf

Discussion in 'Javascript' started by Jess, Mar 17, 2005.

  1. Jess

    Jess Guest

    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?
     
    Jess, Mar 17, 2005
    #1
    1. Advertising

  2. Jess

    otto Guest

    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?
     
    otto, Mar 17, 2005
    #2
    1. Advertising

  3. Jess

    Jess Guest

    How do you use ActionScript to do this?
     
    Jess, Mar 17, 2005
    #3
  4. Jess

    otto Guest

    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.
     
    otto, Mar 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DzemoT.

    ASP.NET & *.swf(Flash files)

    DzemoT., Jan 12, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    13,711
    Udayakumar
    Jan 13, 2004
  2. Trint Smith
    Replies:
    0
    Views:
    531
    Trint Smith
    Feb 27, 2004
  3. =?Utf-8?B?TWlrZQ==?=

    Flash Movie (.swf) does not work on localhost

    =?Utf-8?B?TWlrZQ==?=, Dec 16, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    9,788
  4. Guest

    files di flash . swf

    Guest, Oct 17, 2003, in forum: HTML
    Replies:
    0
    Views:
    522
    Guest
    Oct 17, 2003
  5. Replies:
    0
    Views:
    127
Loading...

Share This Page