01-15-2006, 01:09 AM
|
#1
|
|
Registered User
Join Date: Jul 2004
Posts: 20
|
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.
|
|
|
01-15-2006, 01:10 AM
|
#2
|
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,141
|
dear heavens, no one can read that! Format it.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
|
|
|
01-15-2006, 01:41 AM
|
#3
|
|
Registered User
Join Date: Jul 2004
Posts: 20
|
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.
|
|
|
01-15-2006, 09:14 PM
|
#4
|
|
Registered User
Join Date: Jul 2004
Posts: 20
|
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?????
|
|
|
01-15-2006, 09:27 PM
|
#5
|
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,141
|
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");
|
|
|
01-15-2006, 11:26 PM
|
#6
|
|
Registered User
Join Date: Jul 2004
Posts: 20
|
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 ?
|
|
|
01-16-2006, 02:10 AM
|
#7
|
|
Registered User
Join Date: Jul 2004
Posts: 20
|
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...
|
|
|
01-16-2006, 02:31 AM
|
#8
|
|
Registered User
Join Date: Jul 2004
Posts: 20
|
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.
|
|
|
02-05-2006, 05:42 PM
|
#9
|
|
Senior Member
Join Date: Jan 2006
Posts: 155
|
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.
|
|
|
02-05-2006, 07:04 PM
|
#10
|
|
Banned by AS.org Staff
Join Date: Mar 2002
Posts: 10,533
|
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 08:56 PM.
///
|
|