# Preloader - lill prob

**URL:** <https://forum.kirupa.com/t/preloader-lill-prob/264852>\
**Category:** flash\
**Created:** [July 1, 2008, 8:21am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852 "2008-07-01T08:21:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerome\_chevreau](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jerome\_chevreau](https://forum.kirupa.com/u/jerome_chevreau)\
**Post date:** [July 1, 2008, 8:21am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/1 "2008-07-01T08:21:40Z")

</div>

Hi

i have a bar preloader that i use. i am attaching the preloader on each menu item when the user first click on it. it loads all the content fine but when i click again on another menu item the preloader sti have a bar preloader that i use. i am attaching the preloader on each menu item when the user first click on it. it loads all the content fine but when i click again on another menu item the preloader start at 20%+ and shoots back to almost 0 and then start preloading. I use clear() to clear the empty MC where all the content is loaded and i even remove the preloader on each menu item after preloading to avoid any prob.I have tried everyhting and i cant get any other sol to make it start from 0 every time it loads the menu content. i thought about clearingthe cache but dont know how to do it?!!!

Anyone can provide me with any help.

Thanks art at 20%+ and shoots back to almost 0 and then start preloading. I use clear() to clear the empty MC where all the content is loaded and i even remove the preloader on each menu item after preloading to avoid any prob.I have tried everyhting and i cant get any other sol to make it start from 0 every time it loads the menu content. i thought about clearingthe cache but dont know how to do it?!!!

Anyone can provide me with any help.

Thanks

Jerome

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 1, 2008, 8:24am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/2 "2008-07-01T08:24:48Z")

</div>

you using loadClip() ? or loadMovie()

if it is too much to ask?

---

<div class="post-metadata">

**Author:** ![jerome\_chevreau](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jerome\_chevreau](https://forum.kirupa.com/u/jerome_chevreau)\
**Post date:** [July 1, 2008, 8:39am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/3 "2008-07-01T08:39:02Z")

</div>

I am using loadClip().

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 1, 2008, 8:49am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/4 "2008-07-01T08:49:46Z")

</div>

daft question, but how is your MC in your loader set up?

you may have to set code, which tells it to be 0% until the file has loaded enough for it to know how much has loaded

post your loadClip() function code…

---

<div class="post-metadata">

**Author:** ![jerome\_chevreau](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jerome\_chevreau](https://forum.kirupa.com/u/jerome_chevreau)\
**Post date:** [July 1, 2008, 9:23am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/5 "2008-07-01T09:23:25Z")

</div>

below is the code of the onLoadProgress and onLoadInit.  
I am using one preloader which is attached to the menu item as soon as it starts preloading its swf.

use of attachMovieClip to attach preloader and use of loadClip to load swf.

thanks

> 

loaderListener.onLoadProgress = function(holderClip:MovieClip, loadedBytes:Number, totalBytes:Number):Void {

```
if (Joe1Boolean == true) {
	var JoeNb:Number = 0;
	makePreloaderWork(JoeNb);
	disableMenu();
	
} else if (Joe2Boolean == true) {
	var JoeNb:Number = 1;
	makePreloaderWork(JoeNb);
	disableMenu();
			
} else if (Joe3Boolean == true) {
	var JoeNb:Number = 2;
	makePreloaderWork(JoeNb);
	disableMenu();
			
}else if (Joe4Boolean == true) {
	var JoeNb:Number = 3;
	makePreloaderWork(JoeNb);
	disableMenu();
		}

```

//function to make the preloader work… NEED IT HERE AND NOWHERE ELSE  
function makePreloaderWork(i) {

```
	objectsInScene*.PreLoader_mc.onEnterFrame = function() {
		this._visible = true;//Make the preloader visible again

		if (percent == undefined) {
			percent = 0;
		}
		//------the line of code below is what makes the preloader being smooth      
		percent -= (percent-((loadedBytes/totalBytes)*100)) * 0.25;
		per = int(percent);
		this.percentTxt.text = per+"%";
		this.loadBar._width = per;

		if (percent &gt; 99) {
			this._visible = false;
		}
	};
}

```

};

loaderListener.onLoadInit = function(holderClip:MovieClip):Void {

```
closeBtn.enabled = true;
closeBtn._visible = true;

if (Joe1Boolean == true) {
	var i:Number = 0;
	Tweener.addTween(objectsInScene*.base,{_xscale:Stage.width, _yscale:Stage.height, _alpha:100, time:1, transition:"easeOutQuad"});
	removeMovieClip(objectsInScene*.PreLoader_mc);		
	Movie2Loaded = Movie3Loaded = Movie4Loaded = false;
	Movie1Loaded = true;
	disableMenuBtn(); //function to disable the menu item if swf of this menu has already been loaded
			
} else if (Joe2Boolean == true) {
	var i:Number = 1;
	removeMovieClip(objectsInScene*.PreLoader_mc);
	Tweener.addTween(objectsInScene*.base,{_xscale:Stage.width, _yscale:Stage.height, _alpha:100, time:1, transition:"easeOutQuad"});
	Movie1Loaded = Movie3Loaded = Movie4Loaded = false;
	Movie2Loaded = true;
	disableMenuBtn(); //function to disable the menu item if swf of this menu has already been loaded
	
} else if (Joe3Boolean == true) {
	var i:Number = 2;
	removeMovieClip(objectsInScene*.PreLoader_mc);
	Tweener.addTween(objectsInScene*.base,{_xscale:Stage.width, _yscale:Stage.height, _alpha:100, time:1, transition:"easeOutQuad"});
	Movie1Loaded = Movie2Loaded = Movie4Loaded = false;
	Movie3Loaded = true;
	disableMenuBtn(); //function to disable the menu item if swf of this menu has already been loaded
	
} else if (Joe4Boolean == true) {
	var i:Number = 3;
	removeMovieClip(objectsInScene*.PreLoader_mc);
	Tweener.addTween(objectsInScene*.base,{_xscale:Stage.width, _yscale:Stage.height, _alpha:100, time:1, transition:"easeOutQuad"});
	Movie1Loaded = Movie2Loaded = Movie3Loaded = false;
	Movie4Loaded = true;
	disableMenuBtn(); //function to disable the menu item if swf of this menu has already been loaded
}

```

};

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 1, 2008, 9:46am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/6 "2008-07-01T09:46:55Z")

</div>

loadClip() has its own listeners, it tell you how much is loaded and can control a specific loadbar for the item loading

that should sort out your loadedbar problem and improve your “loaded” variables

> var myMCL = new MovieClipLoader();  
> /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
> //callbacks  
> myMCL.onLoadStart = function(targetMC) {  
> var loadProgress = myMCL.getProgress(targetMC);  
> };  
> myMCL.onLoadProgress = function(targetMC, loadedBytes, totalBytes) {  
> // myTrace (“movie clip: " + targetMC);  
> bigpreview.preloader.preload\_bar.\_xscale = (loadedBytes/totalBytes)\*100;  
> viewer.bar.preload\_bar.\_xscale = (loadedBytes/totalBytes)\*100;  
> if (loadedBytes == totalBytes) {  
> viewer.bar.\_visible = false;  
> } else {  
> viewer.bar.\_visible = true;  
> }  
> [//xmlNode.childNodes](https://xmlNode.childNodes)[selectedNum].childNodes[itemNumber].childNodes[2].childNodes[myVar-1].attributes.url  
> };  
> myMCL.onLoadComplete = function(targetMC) {  
> //trace(“TYU”+ targetMC.\_width + targetMC.\_height)  
> //myTrace (targetMC + " has finished loading.”);  
> var loadProgress = myMCL.getProgress(targetMC);  
> if (targetMC == file0) {  
> //  
> file0.gotoAndStop(itemNumber);  
> }  
> };  
> myMCL.onLoadInit = function(targetMC) {  
> trace(“TYU”+targetMC.\_width+targetMC.\_height);  
> };  
> myMCL.onLoadError = function(targetMC, errorCode) {  
> trace(“error:”+errorCode+" "+targetMC);  
> };

---

<div class="post-metadata">

**Author:** ![jerome\_chevreau](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jerome\_chevreau](https://forum.kirupa.com/u/jerome_chevreau)\
**Post date:** [July 1, 2008, 10:50am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/7 "2008-07-01T10:50:00Z")

</div>

Thanks for your help so far. It may sounds dumb but i have tried one or two things but i cant make start from 0 when the preloader starts again…  
Can you help me in that problem please. Dunno what exactly to write and where to put the piece of code cuz so far my changes (in the onLoadProgress) havent help much…🙂

Thank you

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 1, 2008, 11:02am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/8 "2008-07-01T11:02:55Z")

</div>

daft but I bet you have code somewhere telling it to be at 20% 😛

post the fla, but I don’t promise anything

---

<div class="post-metadata">

**Author:** ![jerome\_chevreau](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jerome\_chevreau](https://forum.kirupa.com/u/jerome_chevreau)\
**Post date:** [July 1, 2008, 11:21am UTC](https://forum.kirupa.com/t/preloader-lill-prob/264852/9 "2008-07-01T11:21:23Z")

</div>

GOING INSANE HERE…dumb mistake…it was the \*.25 in the onLoadProgress in the function making the preloaders work. Think too much code running thru my head, everything starts looking the same…lol…

Thanks so much for your quick replies and putting me on the right track…

Jerome
