Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Preloader for my Preloader :)

0 views
Skip to first unread message

richardpasquarella

unread,
Oct 16, 2008, 12:22:04 PM10/16/08
to
First all, here is what i am speaking about.
http://www.evirtualisting.com

I have a preloader on most of my files. But at times, it is just a black
screen. Then it whips through the preloader in less than a second and appears.
Seems like my preloaders don't work correctly. If it takes 3 minutes to load,
my preloader should be there instantaneaously and then load. But no! Black
screen!!

Does anyone know of a good preloader that works, or how i can fix my
preloaders.

I would even consider embedding a background image (.gif) under my .swf in the
table with just the text," loading", but as i tried this, the background image
does not even show up. Still Black Space.

I need help figuring out how to get rid of all this black space.

here is my preloader code.

// if you set this to true, then the loading animation will be skipped
entirely (if it has already loaded). See instructional PDF for more info.
var skipIfCached = true;

// if you set this to true, the percentage will not show up in the last
hexagon. See instructional PDF for more info.
var hideNumbers = false;

// enter the name of a predefined hexagon color here. See instructional PDF
for more info.
var colorIndex = "frost"
// enter the name of a predefined background color here. See instructional PDF
for more info.
var colorBackgroundIndex = "red";

// this is the intensity of the spotlight. 0 = no light, and 100 = max. See
instructional PDF for more info.
backGlare._alpha = 10;

//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------


// this is an array that defines all of the possible color sets.
presetColors = [
["red", "ED1B23", "9D080D", "FFFF00"],
["orange", "D47300", "8F3500", "FFFF00"],
["yellow", "DFBD00", "AC8A00", "FFFFFF"],
["green", "02A901", "015401", "FFFF00"],
["teal", "00A99D", "006C64", "49FFA3"],
["blue", "0071BC", "004470", "00FFFF"],
["purple", "91268F", "6B0069", "FF00F9"],
["sandstone", "988675", "5F5248", "FFCB91"],
["midnight", "44467B", "313156", "80AAFF"],
["grey", "7D7D7D", "555555", "9AE2FF"],
["tigerseye", "8F5217", "603811", "FFFF00"],
["frost", "A8B2D4", "6679BB", "FFFFFF"],
["black", "222222", "000000", "AAAAAA"],
["neapolitan", "A78165", "7B5A43", "FF75FF"],
["ocean", "62AB6C", "3F7B47", "9BE6FF"],
["pink", "EC008C", "BB006F", "FFFFFF"]
];

// this is an array that defines all of the possible background colors.
presetBackgroundColors = [
["grey", "5A5A5A"],
["red", "725757"],
["orange", "726A57"],
["yellow", "B9BA5C"],
["green", "577259"],
["teal", "577272"],
["blue", "404053"],
["purple", "695772"],
["pink", "BA5CB0"],
["brown", "5D442B"],
["black", "262626"],
["white", "BDBDBD"]
];

// this function finds the name of a color in the "presetColors" array.
function getColorSet() {

// first, check that the value of "colorIndex" is not a number. If it is,
then we don't need to do any searching.
if(colorIndex.length == undefined) {
return;
}else{

// find the color by looping through the "presetColors" array.
for(i in presetColors) {

// see if it is a match.
if(presetColors[i][0] == colorIndex) {
colorIndex = i;
}

}

}
}

// call the "getColorSet" function right after it is defined.
getColorSet();

// this function finds the name of a color in the "presetBackgroundColors"
array.
function getBackgroundColor() {

// first, check that the value of "colorBackgroundIndex" is not a number. If
it is, then we don't need to do any searching.
if(colorBackgroundIndex.length == undefined) {
return;
}else{

// find the color by looping through the "presetBackgroundColors" array.
for(i in presetBackgroundColors) {

// see if it is a match.
if(presetBackgroundColors[i][0] == colorBackgroundIndex) {
colorBackgroundIndex = i;
}

}

}
}

// call the "getBackgroundColor" function right after it is defined.
getBackgroundColor();


//------------------------------------------------------------
//---------- Set Your Own Colors Here ------------------------
//------------------------------------------------------------

// these are the 3 chosen colors of the hexagon. You may enter your own
hexadecimal values as strings.
var colorFace = presetColors[colorIndex][1];
var colorBack = presetColors[colorIndex][2];
var colorAccent = presetColors[colorIndex][3];

// this is the color of the background.
var colorBackground = presetBackgroundColors[colorBackgroundIndex][1];

//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------


// hide all the hexagons until they should appear.
hex12._visible = false;
hex11._visible = false;
hex10._visible = false;
hex9._visible = false;
hex8._visible = false;
hex7._visible = false;
hex6._visible = false;
hex5._visible = false;
hex4._visible = false;
hex3._visible = false;
hex2._visible = false;
hex1._visible = false;

// hide the preloader, so that it doesn't even flicker if it needs to be
skipped over.
this._visible = false;

// hide the percent, if needed.
if(hideNumbers) {
percentHolder._visible = false;
}

// sets a reoccurring action that will trigger until the preloader is done.
this.onEnterFrame = function() {

setPercent(_parent.getBytesLoaded(), _parent.getBytesTotal());

}

// checks the percent loaded, and animates accordingly.
var endAnimation = 0;
function setPercent(amountLoaded, amountTotal) {

// first, calculate the percent loaded.
var thePercent = (amountLoaded / amountTotal) * 100;

// skips the animation entirely if it is already at 100% and the
"skipIfCached" flag is on.
if(skipIfCached && thePercent >= 100) {
_parent.gotoAndPlay(2);
}else{
this._visible = true;
}

// updates the text that displays the percentage.
percentHolder.percent_txt.text = Math.round(thePercent);

// a long set of if-else conditions that animate each hexagon.
if(thePercent >= 100 && hex12._visible) {

// a quick ending animation that fades out the preloader.
if(endAnimation < 25) {
if(endAnimation > 10) {
if(this._alpha > 0) {
this._alpha -= 8;
}
if(backShadow._alpha > 0) {
backShadow._alpha -= 16;
}
}
endAnimation ++;
}else{
_parent.gotoAndPlay(_parent._currentframe + 1);
}

}else if(thePercent >= 96 && hex11._visible) {
if(!hex12._visible) {
percentHolder._visible = false;
hex12._visible = true;
hex12.gotoAndPlay(1);
}
}else if(thePercent >= 88 && hex10._visible) {
if(!hex11._visible) {
hex11._visible = true;
hex11.gotoAndPlay(1);
}
}else if(thePercent >= 80 && hex9._visible) {
if(!hex10._visible) {
hex10._visible = true;
hex10.gotoAndPlay(1);
}
}else if(thePercent >= 72 && hex8._visible) {
if(!hex9._visible) {
hex9._visible = true;
hex9.gotoAndPlay(1);
}
}else if(thePercent >= 64 && hex7._visible) {
if(!hex8._visible) {
hex8._visible = true;
hex8.gotoAndPlay(1);
}
}else if(thePercent >= 56 && hex6._visible) {
if(!hex7._visible) {
hex7._visible = true;
hex7.gotoAndPlay(1);
}
}else if(thePercent >= 48 && hex5._visible) {
if(!hex6._visible) {
hex6._visible = true;
hex6.gotoAndPlay(1);
}
}else if(thePercent >= 40 && hex4._visible) {
if(!hex5._visible) {
hex5._visible = true;
hex5.gotoAndPlay(1);
}
}else if(thePercent >= 32 && hex3._visible) {
if(!hex4._visible) {
hex4._visible = true;
hex4.gotoAndPlay(1);
}
}else if(thePercent >= 24 && hex2._visible) {
if(!hex3._visible) {
hex3._visible = true;
hex3.gotoAndPlay(1);
}
}else if(thePercent >= 16 && hex1._visible) {
if(!hex2._visible) {
hex2._visible = true;
hex2.gotoAndPlay(1);
}
}else if(thePercent >= 8) {
if(!hex1._visible) {
hex1._visible = true;
hex1.gotoAndPlay(1);
}
}

}

// stop the animation one level above the preloader, so that it will wait for
the loading to finish.
_parent.gotoAndStop(_parent._currentframe);
stop();

clbeech

unread,
Oct 16, 2008, 1:22:25 PM10/16/08
to
ok - the real problem here is that you are using the 'actual' file as it loads
to act as the preloader - in this case the majority of the file will load
previous to the preloader initiating anything because it will not function
until the file is instantiated. a much better way of handling this is to use
the MovieClipLoader class and create a 'loading' swf file that IS the
preloader, which in turn 'loads' the actual swf. you then use the
onLoadProgress handler of the MCL class to control the events of the load and
then you can initiate the opening methods in the load file using the onLoadInit
handler.

so you would make a file that is the same size as the main file, then place
your preloader assets and code constructs for the options you're using within
that file - call mcl.loadClip() and load the 'main' swf in that way. the
preloader should then only be a few k at the most and load almost instantly,
and show the progress properly. this is the best way to go when dealing with
large files.

0 new messages