# Preloading Random JPG's

**URL:** <https://forum.kirupa.com/t/preloading-random-jpgs/63149>\
**Category:** Uncategorized\
**Created:** [September 3, 2004, 9:15am UTC](https://forum.kirupa.com/t/preloading-random-jpgs/63149 "2004-09-03T09:15:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![as\_clark20](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@as\_clark20](https://forum.kirupa.com/u/as_clark20)\
**Post date:** [September 3, 2004, 9:15am UTC](https://forum.kirupa.com/t/preloading-random-jpgs/63149/1 "2004-09-03T09:15:31Z")

</div>

Whats the best way to preload randomly called jpg? I have a blank movieclip on screen called “loadit”. So far this works but there is no preloader bar or anything I can call. Anyone got any suggestions?

```auto

// array of all files
filename = ["img1.jpg", "img2.jpg", "img3.jpg", "img4.jpg", "img5.jpg"];

// path to pics
path = "images/";

i = filename.length;
k = Math.floor(Math.random()*i);

// load random 
loadMovie(path+filename[k], loadit);

```

I’d also like the pictures to fade in once loaded but I’m sure that can wait till I’ve got it atleast functioning first eh? Baby steps right.

Please download my FLA if you like.

[download \>\> randomloader.fla](http://www.dataworks.org.uk/fla/randomloader.fla)

Thanks y’all.  
Ads.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2004, 3:11pm UTC](https://forum.kirupa.com/t/preloading-random-jpgs/63149/2 "2004-09-03T15:11:24Z")

</div>

Well, it works exactly the same way every other preloader works:

```auto
loadit.loadMovie (...) ;
this.onEnterFrame = function () {
  var l = getBytesLoaded () ;
  // and so on and so forth
} ;

```

There’s a very nice piece of code in the photo gallery tutorial 🙂
