0

In my app, I want to pick a random image. Each image that I want to pick that is random is like: Myimage1, Myimage2, Myimage3, etc....

So what I do is make an array but the thing that I am concerned about that might be inefficient. So instead of adding images like MyImage1, Myimage2, Myimage3 in my array manually.

Is there an easy way to add all images that start with: Myimage then add them to the array like that?

SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
  • 3
    see http://stackoverflow.com/questions/499673/getting-a-list-of-files-in-a-directory-with-a-glob which should help you in getting a list of the images at runtime. Once you have that, you can randomly pick one. – Nerdtron Nov 06 '11 at 04:09

1 Answers1

1

take the rand function to generate the numbers then by using the string appending you can do

Tendulkar
  • 5,550
  • 2
  • 27
  • 53