I'm using FlashBuilder to create an application that would randomly select two images and place each one in a box. The user would click on the image they prefer, and then a new image would load in the box that they did not click...and so on ad infinitum.
Right now I'm working on loading a random image. I thought about putting all the images in a single directory, and using an HTTPService call to load the image, but I don't know how to randomize it, and if I have a lot of images (over 1,000), I'm concerned that using HTTPService might slow the application down. Is there a way that I can use PHP and MySQL to load the images, and does anyone have any idea of how I would go about loading two random images?
Most of my programming experience comes from WordPress, and I can load two random posts pretty easily with PHP. But I'm not so sure how to do it using Flex.
Can anyone point me in the right direction?
Here is the approach I would take. I would put a stored procedure on the database. Then using php as my middle man i would have it call the store procedure and return the two random images. The key here is to make the database do the heavy lifting for you. you can usen the random fuction
SELECT * FROM `table` ORDER BY RAND() LIMIT 0,1;
let me know if this does not make any sense.
by the way you should look at this post it might point you in the right direction as far as random function and optimization.
Message was edited by: miguel8312
Yes, that's a great solution! Thanks, I'll try it out.