# Preloading Images from database

**URL:** <https://forum.kirupa.com/t/preloading-images-from-database/283543>\
**Category:** flash\
**Created:** [March 7, 2009, 8:42pm UTC](https://forum.kirupa.com/t/preloading-images-from-database/283543 "2009-03-07T20:42:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fry17](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@fry17](https://forum.kirupa.com/u/fry17)\
**Post date:** [March 7, 2009, 8:42pm UTC](https://forum.kirupa.com/t/preloading-images-from-database/283543/1 "2009-03-07T20:42:22Z")

</div>

Hello all,

I have a small problem with preloading images from a database.

Basically i have a folder on my server called ‘work’, i have a database in which when i add a new project a folder is created on the server in the folder ‘work’ and is labeled whatever the id number was of the project created eg. 1,2,3 etc.

In flash i have no problem loading the images into flash via the actionscript below:

```auto

var loader:MovieClipLoader = new MovieClipLoader();
for (i=0; i<=this["total_items"]; i++) {
loadingBar = _root.page_holder.thumbs["loadBar"+i];
Mask = _root.page_holder.thumbs["thumb"+i].mask;
mcImgHolder = _root.page_holder.thumbs["thumb"+i].image;
imgFilename = "work/"+this["id"+i]+"/preview.jpg";
loader.loadClip(imgFilename, mcImgHolder);
this.ref["id_"+i] = this["id"+i];
}

```

What i am after is when someone enters the page the images ‘preview.jpg’ are preloaded in sequence so for instance - thumb1 is loaded first, then when that is complete thumb2 is loaded etc.

I tried to add the following code, however this doesn’t do what i’m after.

```auto

var preload:Object = new Object();
loader.addListener(preload);
preload.onLoadStart = function(target) {
loadingBar._visible = true;
};
preload.onLoadProgress = function(target, loadedBytes, totalBytes) {
loadingBar._xscale = Math.round((loadedBytes/totalBytes)*100);
};
preload.onLoadComplete = function(target) {
Mask.slideTo(null, 0, 1, "easeOutQuad");
};

```

Does anyone know how to help?

Many thanks in advance
