# Preloading Problems

**URL:** https://forum.kirupa.com/t/preloading-problems/161208
**Category:** flash
**Created:** [September 1, 2005, 8:08pm UTC](https://forum.kirupa.com/t/preloading-problems/161208 "2005-09-01T20:08:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sravani](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@sravani](https://forum.kirupa.com/u/sravani)
#### Post date: [September 1, 2005, 8:08pm UTC](https://forum.kirupa.com/t/preloading-problems/161208/1 "2005-09-01T20:08:45Z")

</div>

Hi

I am trying to use an external preloader in my flash file. Here is the code that I placed on the Loading (shared movieclip) in the file to be loaded (The entire animation is in the second scene and only the loader is in the Scene 1)

onClipEvent (load) {  
if (\_parent.getBytesTotal() == \_parent.getBytesLoaded()) {  
quickPlay = true;  
} else {  
preLoad = (\_parent.getBytesTotal() \* 1); //percent to preload  
}  
\_parent.stop();  
}  
onClipEvent (enterFrame) {  
gotoAndStop(loadedIndicatorFrame());  
if (quickPlay == true) { //quickly play the anim  
if (\_currentframe == \_totalframes) {  
\_parent.play();  
}  
} else { //wait for the preload  
if (\_parent.getBytesLoaded() \>= preLoad) {  
\_parent.play();  
}  
}  
}

Here is the code that is placed inside the movie clip on a different flash file called Loader (inside the movieclip Loading, there are 65 frames.).

lastFrame = 1;  
function loadedIndicatorFrame() {  
var newFrame = int((\_parent.getBytesLoaded() / \_parent.getBytesTotal()) \* 65) + 2;  
if (newFrame - lastFrame \> 4) { //too far  
lastFrame += 4;  
loadedText = int(\_parent.getBytesTotal() / 1024 \* (lastFrame - 2) / 65) + "kb of " + int(\_parent.getBytesTotal() / 1024) + “kb”;  
} else if (newFrame - lastFrame \> 0) { //normal move  
lastFrame++;  
loadedText = int(\_parent.getBytesLoaded() / 1024) + "kb of " + int(\_parent.getBytesTotal() / 1024) + “kb”;  
} else { //update the text only  
loadedText = int(\_parent.getBytesLoaded() / 1024) + "kb of " + int(\_parent.getBytesTotal() / 1024) + “kb”;  
}  
return lastFrame;  
}

Somehow the Loader.swf is not called until the whole file that is being loaded is downloaded.

Can you tell me where I am going wrong?

Thanks in advance,  
Sravani
