MUST be a better way... !
Hi all,
I've recently inherited a project which needs to load random images from a dir on the server.
the previous developer has this code on every swf (there are over 40):
- - - - - - - -
pic_arr = ["images/randoms/1", "images/randoms/2","images/randoms/3", "images/randoms/4", "images/randoms/5", "images/randoms/6", "images/randoms/7",
"images/randoms/8", "images/randoms/9","images/randoms/10","images/randoms/11", "images/randoms/12","images/randoms/13","images/randoms/14",
"images/randoms/15","images/randoms/16","images/randoms/17","images/randoms/18","images/randoms/19","images/randoms/20","images/randoms/21",
"images/randoms/22","images/randoms/23","images/randoms/24","images/randoms/25","images/randoms/26","images/randoms/27","images/randoms/28",
"images/randoms/29", "images/randoms/30","images/randoms/31","images/randoms/32"];
ranNum = Math.floor(Math.random()*pic_arr.length);
pic_hold.loadMovie(pic_arr[ranNum]+".jpg");
unloadMovieNum(1);
- - - - - - - - -
I need to update this as the number of random images is set to increase to about 1000 and I don't fancy hand coding the above to include "images/randoms/999" , "images/randoms/1000" !!!
Can anyone suggest a solution where I can keep a single .as file on the server which handles this and then a line of code in each swf which imports it ?
All and any ideas of finding a better solution MUCH appreciated.
FYI - the site is built in php with a Flash fornt end so easy to use php to count the contents of the "images/randoms" dir and pass that number as a flashVar if that helps.
Best wishes
Tony
;