I have a thing i need to make and basically the title says it all…
I need to load random external images with periodic rotation, WITHOUT using a pre-set or coded array.
So basically I want it to look at a specific directory and select any image within that directory (non sequential names preferable but not essential) and display it, then move onto the next random image from the same directory.
Images will be .jpg, not converted to .swf
I have searched and searched these forums and found lots of great info about random image loading, but they all seem to use a pre-defined array where the image names are coded into the actionscript, and unfortunately that would create too many headaches for this particular purpose.
The overall desired application is to be able to upload new images into the selected directory where they will automatically be used within the random image rotation without further editing to the flash itself.
I know how to do it, but I don’t know how to answer without spending an hour hammering out the code for you (which I normally get paid for - hehe). Basically, you’re going to need to name your image sequentially: image1.jpg, image2.jpg etc. There are freeware utils that will do that for you in mass. Search Download.com or the like for file renamers. Change the 62 depending on how many images you have in the folder.
onClipEvent (enterFrame) {
currentTime=getTimer()/1000;
trace (targetTime + " and " + currentTime);
//
if (currentTime>=targetTime) {
targetTime=currentTime+5
x = Math.random() * 62;
p = Math.round(x);
i = “image” + p + “.jpg”;
_root.imageHolder.loadMovie(i);
_root.imageHolder._rotation=70;
} // end if
I was wondering if it’s possible to change the total number of images in the code, in your example it’s 62, to something like 100%
I need to be able to add images to the directory without ammending the flash, and even though there is no coded array, the number of images may change and then it would have a problem…
Also, where in the code does it specify the directory URL?
I think you will have to adjust Kennys code otherwise you could end up with the same images loading.One way would be to have the numbers in an array + shuffle it.
why not just have the image names in a textfile,use loadvars,put them in an array,shuffle the array and loop through it.That way you will know the number of images.
Well the problem is the end user of this is really, really computer illiterate.
Just showing them how to rename their image files and upload them to a server is going to be a REAL chore, so I really need this to be as idiot proof :crazy: as possible…
Otherwise sure, I would just use an array or a text file, no worries…
I don`t know if it is possible for flash to know the number of files in your picture folder.(maybe something serverside???) Perhaps you could teach your client to update just one number in a textfile ie/the total number of movies, that way you could label everything sequentially as kenny as done
and shuffle etc.
all you need to do is use a server-side script to read the directory and send you back a listing which is then put into an array and used as though it was hardcoded like normally.
you could simply have “your newb” edit a text file which contains the number of images in the directory, and then make a random number upto this…
surely they couldn’t find that to hard, otherwise i’m sure there’s some good books on the internet, “computers for newbs” or something along those lines.
if none of the above, do it all for “your newb” and make them pay through the nose
Sorry, but unfortunately we are dealing with “old” people, not newbs…
Old people are different than newbs because newbs have the capacity, and the WILL to learn, these particular old people just don’t want to learn at all and are quite resistant to doing anything out of the ordinary.
Ive found a good image gallery which loads up a random image from any number of folders inside a root image folder. It doesnt cycle them, but all the user would have to do is upload their images - named in any way. The gallery uses php (GD library must be enabled on server), amfphp and flash.
Ill give you more details if you want… should be easy enough to hack apart just for the random image function…