# Preloader (delaying if true) help!

**URL:** <https://forum.kirupa.com/t/preloader-delaying-if-true-help/29920>\
**Category:** flash\
**Created:** [September 2, 2003, 1:33am UTC](https://forum.kirupa.com/t/preloader-delaying-if-true-help/29920 "2003-09-02T01:33:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![soulty](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/soulty/32/105_2.png) [@soulty](https://forum.kirupa.com/u/soulty)\
**Post date:** [September 2, 2003, 1:33am UTC](https://forum.kirupa.com/t/preloader-delaying-if-true-help/29920/1 "2003-09-02T01:33:50Z")

</div>

Hey all

Using the preloader from Smooth tranisitions tut, which is basically a on clip event loop that checks the Total bytes loaded ect… and indicates when the preloader is \_visable (if you want to know exactly what i mean check this link … [http://www.tableau.com.au/tutorials/smooth\_transitions/](http://www.tableau.com.au/tutorials/smooth_transitions/) )

```auto

this.onEnterFrame = function() {
	//this checks to see if the content on this timeline is still loading
	if (this.getBytesLoaded()<this.getBytesTotal()) {
		//make the preloader visible
		_level0.preloaderGraphics._visible=true;
		//make a variable to store the total file size of this timeline
		Total = this.getBytesTotal()/1000;
		//make a variable to store the amount of this timeline that has loaded
		Received = this.getBytesLoaded()/1000;
		//make a variable to store the percentage loaded
		Percentage = (Received/Total)*100;
		//target the text box in the preloaderGraphics mc and tell it what to display
		_level0.preloaderGraphics.percent = int(Percentage) add "%";
		//change the x scale of the progess bar to indicate how much has loaded
		_level0.preloaderGraphics.progressBar._xscale = Percentage;
	} else {
		//play the intro animation
		this.gotoAndPlay("intro");
		//turn off the enterFrame action
		this.onEnterFrame = null;
		//hide the preloader
		_level0.preloaderGraphics._visible=false;
	}
};
//stop this timeline while it loads
stop();

```

this works all fine, though i would prefer if i could have my preloader show for a few seconds even if the movie has been preloaded. I would usually run some variables with some if statments to do this, but with a preloader like the one im using has got me stumped. I’ve come to the conclusion that maybe a delay could be used to let the preloader stay those few seconds (maybe let the dyamic text box read “loaded”).

Any help will be great, thanks 🙂

Soulty:: 😏

---

<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 2, 2003, 5:30pm UTC](https://forum.kirupa.com/t/preloader-delaying-if-true-help/29920/2 "2003-09-02T17:30:27Z")

</div>

[AS]var timer, pause = 2000;  
this.onEnterFrame = function() {  
if (this.getBytesLoaded()\<this.getBytesTotal()) {  
// your code here  
} else {  
if (!timer) timer = getTimer();  
if (getTimer()-timer\>=pause) {  
this.gotoAndPlay(“intro”);  
\_level0.preloaderGraphics.\_visible = false;  
delete this.onEnterFrame;  
}  
}  
};[/AS]  
Read this thread for a brief explanation: [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=33126](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=33126). 😉

---

<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, 2003, 3:36am UTC](https://forum.kirupa.com/t/preloader-delaying-if-true-help/29920/3 "2003-09-03T03:36:05Z")

</div>

Forgot to reply, worked it out using this method, basically the same, just a loop with a if statment.

```auto

_root.siderotate = 1;
this.onEnterFrame = function() {
	//make the preloader visible
	_root.preloader._visible=true;
	//this checks to see if the content on this timeline is still loading
	if (this.getBytesLoaded()<this.getBytesTotal()) {
		//make a variable to store the total file size of this timeline
		Total = this.getBytesTotal()/1000;
		//make a variable to store the amount of this timeline that has loaded
		Received = this.getBytesLoaded()/1000;
		//make a variable to store the percentage loaded
		Percentage = (Received/Total)*100;
		//target the text box in the preloaderGraphics mc and tell it what to display
		_root.preloader.loadText = int(Percentage) add "%";
		} else {
_root.preloader.loadText = "loaded"
time += 1
//adjust '15' to increase/decrese wait time
if (time == 50) {
this.gotoAndPlay("intro");
//turn off the enterFrame action
this.onEnterFrame = null;
//hide the preloader
_root.preloader._visible=false;
}
			}
	
};
//stop this timeline while it loads
stop();

```

With the one you created , do you need to have a variable called pause?

thanks for your help, 😉

---

<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, 2003, 5:07am UTC](https://forum.kirupa.com/t/preloader-delaying-if-true-help/29920/4 "2003-09-03T05:07:32Z")

</div>

…Nope? You may call it whatever you wish. 😛  
Just modify the variable name within the if action, too.
