.each loops over each item in an array. Then you can pass in the
item, here I've done it with clientImg.
clientImgs.each(function(clientImg){
clientImg.set('src', clients.getRandom());
});
Ryan Florence
http://ryanflorence.com/blog
On Jul 27, 2009, at 3:45 AM, mootools.addUser('me'); 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"></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";
> clients[2] = "http://ceoworld.biz/ceo/wp-content/uploads/2009/03/
> nokia-
> logo.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>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MooTools Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/mootools-users?hl=en
-~----------~----~----~----~------~----~------~--~---