Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-15-2006, 01:09 AM   #1
vibetribe
Registered User
 
Join Date: Jul 2004
Posts: 20
Default The MULTIPLE MC preloader,,, :) [SOLVED]!!!!

This is the current AS i wrote for 25 empty MCs which need to preload 25 jpegs.... it works kinda sorta hit and miss,, is there any code more efficient? and reliable?

Code:
this.onEnterFrame = function() {
	theLoading = (_root.mcSmall1.getBytesLoaded()+_root.mcSmall2.getBytesLoaded()+_root.mcSmall3.getBytesLoaded()+_root.mcSmall4.getBytesLoaded()+_root.mcSmall5.getBytesLoaded()+_root.mcSmall6.getBytesLoaded()+_root.mcSmall7.getBytesLoaded()+_root.mcSmall8.getBytesLoaded()+_root.mcSmall9.getBytesLoaded()+_root.mcSmall10.getBytesLoaded()+_root.mcSmall11.getBytesLoaded()+_root.mcSmall12.getBytesLoaded()+_root.mcSmall13.getBytesLoaded()+_root.mcSmall14.getBytesLoaded()+_root.mcSmall15.getBytesLoaded()+_root.mcSmall16.getBytesLoaded()+_root.mcSmall17.getBytesLoaded()+_root.mcSmall18.getBytesLoaded()+_root.mcSmall19.getBytesLoaded()+_root.mcSmall20.getBytesLoaded()+_root.mcSmall21.getBytesLoaded()+_root.mcSmall22.getBytesLoaded()+_root.mcSmall23.getBytesLoaded()+_root.mcSmall24.getBytesLoaded());
	theLoaded = (_root.mcSmall1.getBytesTotal()+_root.mcSmall2.getBytesTotal()+_root.mcSmall3.getBytesTotal()+_root.mcSmall4.getBytesTotal()+_root.mcSmall5.getBytesTotal()+_root.mcSmall6.getBytesTotal()+_root.mcSmall7.getBytesTotal()+_root.mcSmall8.getBytesTotal()+_root.mcSmall9.getBytesTotal()+_root.mcSmall10.getBytesTotal()+_root.mcSmall11.getBytesTotal()+_root.mcSmall12.getBytesTotal()+_root.mcSmall13.getBytesTotal()+_root.mcSmall14.getBytesTotal()+_root.mcSmall15.getBytesTotal()+_root.mcSmall16.getBytesTotal()+_root.mcSmall17.getBytesTotal()+_root.mcSmall18.getBytesTotal()+_root.mcSmall19.getBytesTotal()+_root.mcSmall20.getBytesTotal()+_root.mcSmall21.getBytesTotal()+_root.mcSmall22.getBytesTotal()+_root.mcSmall23.getBytesTotal()+_root.mcSmall24.getBytesTotal());
	percent = (theLoading/theLoaded)*100;
	if (!isNan(percent)) {
		if (percent == 0) {
			percent_display = "";
		} else {
			percent_display = Math.ceil(percent)+"%";
		}
		if (percent>1) {
			_root.mcLoadPane._visible = true;
		}
		_root.scrollclip._visible = false;
	}
	if (percent == 100) {
		this.gotoAndStop(1);
		_root.mcLoadPane._visible = false;
		delete this.onEnterFrame;
		percent_display = "";
		_root.scrollclip._visible = true;
	}
};
stop();
Many thanks in advance for those that can help,,,

avi

www.thedirectorscut.org

Last edited by vibetribe; 01-16-2006 at 02:23 AM.
vibetribe is offline   Reply With Quote
Old 01-15-2006, 01:10 AM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

dear heavens, no one can read that! Format it.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 01-15-2006, 01:41 AM   #3
vibetribe
Registered User
 
Join Date: Jul 2004
Posts: 20
Default

could have swarn i did the (code) thing,, oh well,, there u have it

I also tried this,, which i believe would probably be a more forward thinking option,, but for some reason it doesnt work properly either,,, the mcScrollPane becomes invisible and all jpegs show except for 2,,, point is ,, if the code is working,, the mcScrollPane should not dissapear until ALL jpegs are loaded,,,

anyway ,, here is the other code i tried to do what i just described ,,,

Code:
//trace function
_root.scrollclip._visible = false;
_root.mcLoadPane._visible = true;
/*********************************************************************/
//init
var myMCL = new MovieClipLoader();
/*********************************************************************/
//callbacks
myMCL.onLoadStart = function(targetMC) {
	var loadProgress = myMCL.getProgress(targetMC);
	trace("The movieclip "+targetMC+" has started loading");
	trace("Bytes loaded at start="+loadProgress.bytesLoaded);
	trace("Total bytes loaded at start="+loadProgress.bytesTotal);
	trace("____________________________________");
	_root.scrollclip._visible = false;
	_root.mcLoadPane._visible = true;
};
myMCL.onLoadProgress = function(targetMC, loadedBytes, totalBytes) {
	trace("movie clip: "+targetMC);
	trace("Bytes loaded at progress callback="+loadedBytes);
	trace("Bytes total at progress callback="+totalBytes);
	trace("____________________________________");
	_root.scrollclip._visible = false;
	_root.mcLoadPane._visible = true;
};
myMCL.onLoadComplete = function(targetMC) {
	trace(targetMC+" has finished loading.");
	var loadProgress = myMCL.getProgress(targetMC);
	trace("Bytes loaded at end="+loadProgress.bytesLoaded);
	trace("Bytes total at end="+loadProgress.bytesTotal);
	trace("____________________________________");
	_root.scrollclip._visible = false;
	_root.mcLoadPane._visible = true;
};
myMCL.onLoadInit = function(targetMC) {
	trace("Movie clip:"+targetMC+" is now initialized");
	targetMC._width = 72;
	targetMC._height = 90;
	trace("____________________________________");
      _root.scrollclip._visible = true;
	_root.mcLoadPane._visible = false;
};
/********************************************************************/
//load the files in to their respective targets
myMCL.loadClip("dc_images/small1.jpg", "_root.scrollclip.movStrip1.mcSmall1");
myMCL.loadClip("dc_images/small2.jpg", "_root.scrollclip.movStrip1.mcSmall2");
myMCL.loadClip("dc_images/small3.jpg", "_root.scrollclip.movStrip1.mcSmall3");
myMCL.loadClip("dc_images/small4.jpg", "_root.scrollclip.movStrip1.mcSmall4");
myMCL.loadClip("dc_images/small5.jpg", "_root.scrollclip.movStrip1.mcSmall5");
myMCL.loadClip("dc_images/small6.jpg", "_root.scrollclip.movStrip1.mcSmall6");
myMCL.loadClip("dc_images/small7.jpg", "_root.scrollclip.movStrip1.mcSmall7");
myMCL.loadClip("dc_images/small8.jpg", "_root.scrollclip.movStrip1.mcSmall8");
myMCL.loadClip("dc_images/small9.jpg", "_root.scrollclip.movStrip1.mcSmall9");
myMCL.loadClip("dc_images/small10.jpg", "_root.scrollclip.movStrip1.mcSmall10");
myMCL.loadClip("dc_images/small11.jpg", "_root.scrollclip.movStrip1.mcSmall11");
myMCL.loadClip("dc_images/small12.jpg", "_root.scrollclip.movStrip1.mcSmall12");
myMCL.loadClip("dc_images/small13.jpg", "_root.scrollclip.movStrip1.mcSmall13");
myMCL.loadClip("dc_images/small14.jpg", "_root.scrollclip.movStrip1.mcSmall14");
myMCL.loadClip("dc_images/small15.jpg", "_root.scrollclip.movStrip1.mcSmall15");
myMCL.loadClip("dc_images/small16.jpg", "_root.scrollclip.movStrip1.mcSmall16");
myMCL.loadClip("dc_images/small17.jpg", "_root.scrollclip.movStrip1.mcSmall17");
myMCL.loadClip("dc_images/small18.jpg", "_root.scrollclip.movStrip1.mcSmall18");
myMCL.loadClip("dc_images/small19.jpg", "_root.scrollclip.movStrip1.mcSmall19");
myMCL.loadClip("dc_images/small20.jpg", "_root.scrollclip.movStrip1.mcSmall20");
myMCL.loadClip("dc_images/small1.jpg", "_root.scrollclip.movStrip1.mcSmall21");
myMCL.loadClip("dc_images/small2.jpg", "_root.scrollclip.movStrip1.mcSmall22");
myMCL.loadClip("dc_images/small3.jpg", "_root.scrollclip.movStrip1.mcSmall23");
myMCL.loadClip("dc_images/small4.jpg", "_root.scrollclip.movStrip1.mcSmall24");
myMCL.loadClip("dc_images/small5.jpg", "_root.scrollclip.movStrip1.mcSmall25");

Last edited by vibetribe; 01-15-2006 at 03:59 AM.
vibetribe is offline   Reply With Quote
Old 01-15-2006, 09:14 PM   #4
vibetribe
Registered User
 
Join Date: Jul 2004
Posts: 20
Default

ok ,,, no one have any ideas???? how to make this A NONE SEQUENTIAL preloader,,, i need them all to load before anything happens,, ie,,,

no jpegs can be seen until the sum of ALL jpegs are loaded.

Anyone?????
vibetribe is offline   Reply With Quote
Old 01-15-2006, 09:27 PM   #5
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

you first code looks alright to me ( a little funky in some places) but it look like it should work. However, that kind of preloaders never do, i have no idea why?

Oldnewbie????
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 01-15-2006, 11:26 PM   #6
vibetribe
Registered User
 
Join Date: Jul 2004
Posts: 20
Default

awwwww,,, after reading other posts on all the boards,, i think if this can be answered, alot of people would be very happy,,

its one thing to do multiple preloader for AS invoked mcs,, but another to apply it to MCs already on the timeline,,,

oldnewbie,, my old flashkit master,,, what say u ?
vibetribe is offline   Reply With Quote
Old 01-16-2006, 02:10 AM   #7
vibetribe
Registered User
 
Join Date: Jul 2004
Posts: 20
Default

I have an idea,,, can u do the following?

Code:
myMCL.onLoadInit = function(targetMC) {
//have some code to at "1" to a number var/object  everytime onLoadInit is reached for a loaded jpeg.
};
for example
a jpeg completes loading, AS ads 1 to and object so when that object equals a certain number (eg, 25 for the 25 movie im loading), then whatever needs happening can happen ie, play this do that etc...
vibetribe is offline   Reply With Quote
Old 01-16-2006, 02:31 AM   #8
vibetribe
Registered User
 
Join Date: Jul 2004
Posts: 20
Default

SO VERY DAMN SIMPLE,,, I was staring,, and it just came to me , HOPE THIS HELPS EVERYONE ELSE


Code:
stop();
var counting = 0;
myMCL.onLoadInit = function(targetMC) {
	counting = counting+1;
	if (counting == 25) {//this is the crux of it ,,, simply put the amount of jpegs u are preloading here,,, and it will do everything when it has loaded that amount,, in this case, 25 jpegs YAY
		play();//or whatever u want your movie to do next  YAY AGAIN 
	}
	trace(counting);//i just put this so u can see it counting, how glorious
}
myMCL.loadClip("dc_images/small1.jpg", "_root.mcSmall1");
myMCL.loadClip("dc_images/small2.jpg", "_root.mcSmall2");
//yadda yadda yadda
myMCL.loadClip("dc_images/small25.jpg", "_root.mcSmall25");

Last edited by vibetribe; 01-16-2006 at 02:40 AM.
vibetribe is offline   Reply With Quote
Old 02-05-2006, 05:42 PM   #9
nfh
Senior Member
 
Join Date: Jan 2006
Posts: 155
Default

Quote:
Originally Posted by vibetribe
SO VERY DAMN SIMPLE,,, I was staring,, and it just came to me , HOPE THIS HELPS EVERYONE ELSE


Code:
stop();
var counting = 0;
myMCL.onLoadInit = function(targetMC) {
	counting = counting+1;
	if (counting == 25) {//this is the crux of it ,,, simply put the amount of jpegs u are preloading here,,, and it will do everything when it has loaded that amount,, in this case, 25 jpegs YAY
		play();//or whatever u want your movie to do next  YAY AGAIN 
	}
	trace(counting);//i just put this so u can see it counting, how glorious
}
myMCL.loadClip("dc_images/small1.jpg", "_root.mcSmall1");
myMCL.loadClip("dc_images/small2.jpg", "_root.mcSmall2");
//yadda yadda yadda
myMCL.loadClip("dc_images/small25.jpg", "_root.mcSmall25");
Does Flash/Actionscript have any semaphore mechanism that allows exclusive access to variables? For instance, in the (remote) case that two or more images (in your example) are loaded at the exact same time, the onLoadInit event is also generated at the same time. This means that the "couting" variable will have the same value on both event calls. This also means that in the end the "counting" variable could end up with a value smaller than 25. With an exclusive access mechanism the first event that gets the "counting" value would lock the variable so that it gets freed only after it increments the value and not before.
nfh is offline   Reply With Quote
Old 02-05-2006, 07:04 PM   #10
oldnewbie
Banned by AS.org Staff
 
Join Date: Mar 2002
Posts: 10,533
Default

http://www.actionscript.org/tutorial...04/index.shtml
oldnewbie is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd IE issues with a preloader ajdphoto ActionScript 2.0 2 03-17-2008 08:10 AM
multiple preloader suzu Simple Stuff (Newbies) 1 10-24-2005 05:37 PM
multiple external movie preloader !!! help!!! florinsasioan Components 0 05-11-2005 07:00 AM
Multiple Preloader Tutorial by FlashVaccum Flash Gordon ActionScript 2.0 3 04-17-2005 04:36 PM
One preloader w/ multiple movies silent7 ActionScript 1.0 (and below) 0 12-16-2004 12:02 PM


All times are GMT. The time now is 08:16 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.