Results 1 to 2 of 2

Thread: Random Flash Script Need Help.

  1. #1
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Random Flash Script Need Help.

    Hi Everyone. I can not for the life of me figure out what is wrong with this script. It has some sort of bug that it comes up blank sometimes. Can anyone help me fix it and or give me a new script? I am just simply trying to create a random flash movie that plays every time you load the page.

    Here is a URL of the loaded page, just refresh it a few times and it will go blank on ya... DOh....

    http://www.isu.edu/asisu/test/randomtest.shtml

    Here is the script:

    <script type="text/javascript">

    swfFiles= new Array()
    //Set Flash sources, widths and heights
    swfFiles[0]=['turn.swf', 539, 200 ]
    swfFiles[1]=['turn2.swf', 539, 200 ]
    swfFiles[2]=['turn3.swf', 539, 200 ]
    swfFiles[4]=['turn4.swf', 539, 200 ]
    swfFiles[5]=['turn5.swf', 539, 200 ]
    swfFiles[6]=['turn6.swf', 539, 200 ]

    ////////////////No Need to Edit Below Here//////////////

    //Randomizing Unit Courtesy of Mike Winter as seen at:
    //http://www.dynamicdrive.com/forums/showthread.php?p=8442
    function random(n) {
    return Math.floor((Math.random() % 1) * n);
    }

    Array.prototype.shuffle = function() {var i = this.length;
    while(i--) {this.swap(i, random(i + 1));}
    };
    Array.prototype.swap = function(x, y) {
    var t = this[x]; this[x] = this[y]; this[y] = t;
    };

    swfFiles.shuffle()
    //End Randomizing Unit


    document.write('\
    <OBJECT CLASSID="clsid27CDB6E-AE6D-11cf-96B8-444553540000" \
    CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" \
    HEIGHT="'+swfFiles[0][2]+'" WIDTH="'+swfFiles[0][1]+'" ALIGN=""> \
    <PARAM NAME="movie" VALUE="'+swfFiles[0][0]+'"> \
    <PARAM NAME="quality" VALUE="high"> \
    <embed src="'+swfFiles[0][0]+'" \
    quality="high" \
    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" \
    type="application/x-shockwave-flash" \
    height="'+swfFiles[0][2]+'" width="'+swfFiles[0][1]+'"></embed> \
    </object>\
    ')
    </script>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    swfFiles= new Array()
    //Set Flash sources, widths and heights
    swfFiles[0]=['turn.swf', 539, 200 ]
    swfFiles[1]=['turn2.swf', 539, 200 ]
    swfFiles[2]=['turn3.swf', 539, 200 ]
    swfFiles[4]=['turn4.swf', 539, 200 ]
    swfFiles[5]=['turn5.swf', 539, 200 ]
    swfFiles[6]=['turn6.swf', 539, 200 ]
    You are missing a "swfFiles[3]". Without that, in this type of situation, one is assumed but, one with no values assigned. When that one gets selected by the randomizing unit, that is probably the cause of the problem.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •