Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Guys quick question please... 3

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
ok i have navigation on main movie. level 0.

when i click a button i want a loading clip to become visable (which initialy will be false) , check for the total loaded of external swf to be loaded to level 1, if loaded, loading clip visable false, load movie level 1.

I have a total of 9 buttons that i would like to all work in the same way. on press kill previously loaded movie, loading clip visable true, if external loaded, kill loading clip, play external in level 1.

all done locally, is a presentation.

I can't seem to get it right,
an example guys?

Thanks in advance...

---------------------------------------------
 
Maybe something like this:

Code:
//BUTTON CLASS
LoadButton = function (i) {
	//get button clip from library and place it on stage, setting up an id
	this.clip = attachMovie('buttonClip', 'button'+i, i, {_x:40*i, _y:300, id:i});
	this.clip.onRelease = function() {
		this.doLoad(this.id);
	};
};
//ADD METHODS TO THE MOVIECLIP CLASS
MovieClip.prototype.doLoad = function(i) {
	//make loader visible and find movie to load
	loaderClip._visible = 1;
	loadMovieNum('myMovie'+i+'.swf', 1);
	this.onEnterFrame = this.checkLoad;
};
MovieClip.prototype.checkLoad = function() {
	//run progress counter if you want one
	loaderClip.progress = Math.round(_level1.getBytesLoaded()/_level1.getBytesTotal()*100);
	if (loaderClip.progress>=100) {// maybe add a 2nd condition here to prevent false readings
		loaderClip._visible = 0;
		//set new movie going (have a blank frame and stop() on frame 1 to keep it invisible during the load)
		_level1.play();
		this.onEnterFrame = null;
	}
};
//SET UP BUTTONS
loaderClip._visible = 0;
for (var i = 1; i<=9; i++) {
	//create new button object
	this['loadbutton'+i] = new LoadButton(i);
}
//
stop();

This sets up the buttons and actions within a loop so that you don't have nine 'on release's to do, then the loading and progress indicators are added as extensions to the movieclip class so you can call them from anywhere.

The button is attached from the library (stick it inside a mc for convenience).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top