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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pre-Loader Not working when published 1

Status
Not open for further replies.

lukeduke7

Technical User
Aug 29, 2007
3
US
Hello, I'm new to this forum. I have situation with my preloader. I am loading audio from an external folder. When I click on the audio a preloader loads the audio and upon completion plays audio.

My problem lies in that when I test the movie everything works as expected. I was joyous. BUT, once I view the actual .swf or the .exe after I publish, the preloader doesn't work. The audio still loads but the preloader does nothing.

Does anyone know what I might be doing wrong? Is there a setting in the publish settings I need to change.

This is the first time I've had this happen. Usually I have a pre-loader at the begining of a flash file and load the file. This one is in a movie clip and only activated upon a mouse action.

Any help or suggestions is greatly appreciated.

//ACTION SCRIPT I AM USING (AS2)//
Code:
switchTrack = function (trackNr) {
mcLoader.mcBar._visible = true;
txtPercent._visible = true;
snd.stop();
snd.loadSound(soundUrls[trackNr]);
bt = snd.getBytesTotal();
this.onEnterFrame = function () {
bl = snd.getBytesLoaded();
pr = bl/bt*100;
txtPercent.text = 'LOADING '+Math.ceil(pr)+'%';
mcBar._xscale = pr;
if (pr == 100) {
mcBar._visible = false;//Hide pre-loader bar after load
txtPercent._visible = false;//Hide pre-loader text after load
_parent.mcSoundStop._visible = true;
_parent.mcSoundPlay._visible = false;
snd.setVolume(100);
delete this.onEnterFrame;
}
}
}
 
Not really, its company material and highly confidential. Have you heard of this before or have any possible suggestions? Thanks!
 
This following code works...

Code:
mcBar._visible = false;

//PRE-LOADER and TRACK PLAY
switchTrack = function (trackNr) {
	mcBar._visible = false;
	txtPercent._visible = false;
	snd.stop();
	snd.loadSound(soundUrls[trackNr]);
	this.onEnterFrame = function () {
		pr = snd.getBytesLoaded()/snd.getBytesTotal()*100;
		if(!isNaN(pr)){
			if (pr == 0) {
				txtPercent.text = "";
			} else {
				trace(pr);
				txtPercent._visible = true;
				txtPercent.text = 'LOADING '+Math.ceil(pr)+'%';
			}
			mcBar._visible = true;
			mcBar._xscale = pr;
    	}
		if (pr == 100) {
			mcBar._visible = false;
			txtPercent._visible = false;
			_parent.mcSoundStop._visible = true;
			_parent.mcSoundPlay._visible = false;
			snd.setVolume(100);
			delete this.onEnterFrame;
		}
	};
};

Note that you'll have to correct your code on the loadBar, since only the outline scales, since you haven't added the loadbar fill mc itself within that loadBar mc.

Furthermore, the preloader doesn't re-appear once the files are cached, and you'll need to clear your cache between tests, if you want to see it in action again.

That's why I'd also make the bar outline on stage invisible to start with, and only make it visible (as the main loadBar) when needed, that is if the file is not already cached.

Regards. FLASH HELP - OPENED FOR BUSINESS!
TO GET YOUR OWN FREE WEBSITE HOSTING
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top