clientImgs.each(function(el, i){
        var index = $random(0, clients.length - 1);
        clientImgs[i].set('src', clients[index]);
        clients.splice(index, 1);
    });

or if you know the number of elements in the clientImgs array you don't need
the .each


On Mon, Jul 27, 2009 at 12:45 PM, mootools.addUser('me'); <
[email protected]> wrote:

>
> Hi,
>
> heres the situation:
>
> i have an array of img srcs and i also have four img tags. each img
> tag grabs a random src from the array, but heres the problem:
>
> i only want srcs to be grabbed once! any help would be very much
> appreciated!!
>
> code:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Untitled Document</title>
> <script type="text/javascript" src="http://demos.mootools.net/demos/
> mootools.js <http://demos.mootools.net/demos/%0Amootools.js>"></script>
> <script type="text/javascript">
> window.addEvent('domready', function(){
> var clients = new Array();
> clients[0] = "http://mootools.net/assets/images/mootools.png";;
> clients[1] = "http://www.techdigest.tv/assets_c/2009/02/google-chrome-
> logo-thumb-300x300-75857.jpg<http://www.techdigest.tv/assets_c/2009/02/google-chrome-%0Alogo-thumb-300x300-75857.jpg>
> ";
> clients[2] = "http://ceoworld.biz/ceo/wp-content/uploads/2009/03/nokia-
> logo.bmp<http://ceoworld.biz/ceo/wp-content/uploads/2009/03/nokia-%0Alogo.bmp>
> ";
> clients[3] = "http://www.google.co.uk/intl/en_uk/images/logo.gif";;
> var clientImgs = $('clientImg').getElements('img');
> clientImgs.each(function(){
> clientImgs[0].set('src', clients.getRandom());
> clientImgs[1].set('src', clients.getRandom());
> clientImgs[2].set('src', clients.getRandom());
> clientImgs[3].set('src', clients.getRandom());
> });
> $$('#clientImg img').tween('height', '25%', '100%');
> $$('#clientImg img').tween('width', '25%', '100%');
> });
> </script>
> <style type="text/css">
> #clientImg {
> width:450px;
> height:350px;
> overflow:hidden;
> text-align:center;
> }
> </style>
> </head>
>
> <body>
> <div id="clientImg">
> <img class="client" /><img class="client" /><img class="client" /><img
> class="client" />
> </div>
> </body>
> </html>
>

Reply via email to