Preloader (delaying if true) help!

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/ )



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 :slight_smile:

Soulty:: :smirk:

[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. :wink:

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


_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, :wink:

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