# \[HELP\] preloader for dynamically loading img

**URL:** https://forum.kirupa.com/t/help-preloader-for-dynamically-loading-img/40502
**Category:** flash
**Created:** [January 19, 2004, 10:03am UTC](https://forum.kirupa.com/t/help-preloader-for-dynamically-loading-img/40502 "2004-01-19T10:03:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mahesh\_r](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@mahesh\_r](https://forum.kirupa.com/u/mahesh_r)
#### Post date: [January 19, 2004, 10:03am UTC](https://forum.kirupa.com/t/help-preloader-for-dynamically-loading-img/40502/1 "2004-01-19T10:03:11Z")

</div>

Hi Flash Guru’s,

I am having a lot of trouble to get a preloader working for this code.

Short Desc: i have a listbox which gets the data from XML page. once i click on any on of the lable in the listbox, a image loads in a movieclip.

I am trying to add a preloader to the moviclip. the code below is what iam using:

```auto
 _root.procent = Math.round((_root.scrollpane_sp.getBytesLoaded()/_root.scrollpane_sp.getBytesTotal())*100);

```

The loader movieclip has the onClipevent code.

Here is the full code:

[AS]onItemSelect = function () {  
var imgSrc = listBox.getSelectedItem().data  
scrollpane\_sp.loadScrollContent(imgSrc,“onScrollContentLoaded”,this)  
\_root.procent = Math.round((\_root.scrollpane\_sp.getBytesLoaded()/\_root.scrollpane\_sp.getBytesTotal())\*100);  
//display loading screen here  
}

onScrollContentLoaded = function () {  
trace(“content finished loading”)  
//hide loading screen here  
}

listBox.setChangeHandler(“onItemSelect”,this)[/AS]
