[Flashr] Is random display possible?
Kelvin Luck
kelvin at kelvinluck.com
Mon Apr 16 04:25:16 EDT 2007
On Sun, 15 Apr 2007 01:05:40 +0100, Jeff Kastner <jeffkastner at gmail.com> wrote:
> Brand new here, so I apologize for what is surely a duplicate question, but
> I don't yet see anywhere I can search. I got Flashr working on my site.
> Now, I'm curious to know if random display of pictures is possible.. instead
> of displaying the same order every time?
> Thank you.
>
Hi Jeff,
Welcome to the list :)
Yes, it is possible to display pictures in a random order although it depends how you are getting your list of pictures. The Flickr API doesn't provide any method for sorting randomly so you will need to collect all the pictures and then sort the list randomly before displaying them. So for example, if you are using Flashr.photosSearch to get your list of photos you could do something like this in your onPhotosSearch function (untested code typed straight into the email but should work):
function onPhotosSearch(rs:ResultsSet)
{
var p:Array = rs.photos;
p.sort(function() {
return Math.round(Math.random())? 1:-1;
});
// do something with the p array to display the pictures.
}
Hope that helps,
Kelvin :)
More information about the Flashr
mailing list