2

Hello overflow I am making a flash gallery(which is complete) and I would like to create a page where it takes 10 random flashs from my arrays and make them all play simultaneously to create something truly cancerous. I have played around with this for a while now and would think that there would be a more efficent and maybe even a way that actually WORKS :D.

HTML

<body>

    <div class="titleText">
        <a href="index.html" class="downlink">
        <h1>Craz Page</h1>
            </a>
    </div>

    <div class="flashmoviecraz" id="flashmoviecraz1">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz2">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz3">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz4">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz5">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz6">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz7">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz8">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz9">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>
    <div class="flashmoviecraz" id="flashmoviecraz10">
        <object type="application/x-shockwave-flash" data="">'+
            <param name="movie" value="">
        </object>
    </div>

JAVASCRIPT

$(document).ready(function () {
    var paths = [
'swfs/#1%20(Special%20Japanese%20Extended%20Dance%20Mix).swf',
'swfs/$D6.swf',
'swfs/(MAD)%20Huh.swf',
'swfs/(^q^)冷やしくおえうえーーーるえうおおお%20FIXED.swf',
'swfs/(ノ^∇^)ノ☎------[](; ̄Д ̄).swf',
'swfs/-(。ヘ°).swf',
'swfs/-ppppSuperWiiUv5_2.swf',
'swfs/0x40%20Hues%20v4n20.swf',
'swfs/0x40%20Huеs%20of%20Winter.swf',
'swfs/10r.swf',
'swfs/1421379050663.swf'];

var a,b,c,d,e,f,g,h,k,j = 0;
    var flashmovie, flashmoviecraz1, flashmoviecraz2, flashmoviecraz3, flashmoviecraz4, flashmoviecraz5, flashmoviecraz6, flashmoviecraz7, flashmoviecraz8, flashmoviecraz9, flashmoviecraz10, 
        test, temp;

    var randomIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];  // 0 to N-1
    shuffle(randomIndices);

    function craz() {

        flashmoviecraz1 = document.getElementById('flashmoviecraz1');
        flashmoviecraz2 = document.getElementById('flashmoviecraz2');
        flashmoviecraz3 = document.getElementById('flashmoviecraz3');
        flashmoviecraz4 = document.getElementById('flashmoviecraz4');
        flashmoviecraz5 = document.getElementById('flashmoviecraz5');
        flashmoviecraz6 = document.getElementById('flashmoviecraz6');
        flashmoviecraz7 = document.getElementById('flashmoviecraz7');
        flashmoviecraz8 = document.getElementById('flashmoviecraz8');
        flashmoviecraz9 = document.getElementById('flashmoviecraz9');
        flashmoviecraz10 = document.getElementById('flashmoviecraz10');


        flashmoviecraz1.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[0] + '">' +
            '<param name="movie" value="' + paths[0] + '">' +
            '<\/object>';

        flashmoviecraz2.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[1] + '">' +
            '<param name="movie" value="' + paths[1] + '">' +
            '<\/object>';

        flashmoviecraz3.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[2] + '">' +
            '<param name="movie" value="' + paths[2] + '">' +
            '<\/object>';
        flashmoviecraz4.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[3] + '">' +
            '<param name="movie" value="' + paths[3] + '">' +
            '<\/object>';
        flashmoviecraz5.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[4] + '">' +
            '<param name="movie" value="' + paths[4] + '">' +
            '<\/object>';
        flashmoviecraz6.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[5] + '">' +
            '<param name="movie" value="' + paths[5] + '">' +
            '<\/object>';
        flashmoviecraz7.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[6] + '">' +
            '<param name="movie" value="' + paths[6] + '">' +
            '<\/object>';
        flashmoviecraz8.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[7] + '">' +
            '<param name="movie" value="' + paths[7] + '">' +
            '<\/object>';
        flashmoviecraz9.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[8] + '">' +
            '<param name="movie" value="' + paths[8] + '">' +
            '<\/object>';
        flashmoviecraz10.innerHTML =
            '<object type="application/x-shockwave-flash" data="' + paths[9] + '">' +
            '<param name="movie" value="' + paths[9] + '">' +
            '<\/object>';
    }

      window.addEventLister ?
        window.addEventListener('load', craz, false) :
        window.attachEvent('onload', craz);
});
cosmichero2025
  • 1,029
  • 4
  • 14
  • 37

1 Answers1

2

As I see it, your first problem is that you're using the same random c index to pick the paths of all videos. You should generate a new random index for each video.

Try this:

// Shuffle function found here: http://stackoverflow.com/a/6274381/1305067
var randomIndices = [0, 1, 2, 3, 4, 5];  // 0 to N-1
shuffle(randomIndices);

For each video, get randomIndices[0], randomIndices[1], and so on...

paulvs
  • 11,963
  • 3
  • 41
  • 66
  • Oh I know that I'll need unique things for all the flashs I just thought that it would be beneficial to get at least them all working with one index then later when that problem is solved to repeat the process of index randomization. – cosmichero2025 Apr 13 '16 at 03:18
  • Actually now that you say that I probably should have done that before i posted the question...... – cosmichero2025 Apr 13 '16 at 03:19
  • Alright I edited the question did I implement it correctly? – cosmichero2025 Apr 13 '16 at 03:30