all groups > flash actionscript > april 2004 >
You're in the

flash actionscript

group:

preloader code help


preloader code help AlexisNeel
4/2/2004 11:49:09 PM
flash actionscript:
Hi and thanks in advance for any input you can give.

Here's what I would like to do:

First, go here and you can where I am at present:

[L=current preloader]http://www.alexisneel.com/test/BWshortTest2.html[/L]


You will notice that everything's works according to plan. However, what I
would like to happen is this...

I would like to retain the "percentage loaded" amount showing up as it does
now, and continue to go from 0% to 100%. However, what I would like that
100% to represent is actually only about 1/3 of the actual total amount of
the file size. In other words, as it stands, it does take some time to load
such a big file. Granted the viewer can see that it is progressing (a good
thing), but I'd like to take advantage of the Flash feature that allows the
viewer to start viewing something before it is actually totally loaded. For
example, go to the main part of my [L=site]http://www.alexisneel.com/en/[/L]
You
will see the "loading" happening (this is being done with "ifFrameloaded" and
"gotoAndPlay" code). Fine. But the movie starts way before
the whole file is loaded. You are just getting enough to start viewing the
page and the rest is still downloading. Now click on "galleries", then on one
of the images. Again, you will see "Loading" and in just a few seconds, you
will start to see the images fading in. In actuality, even though you are
starting to see the movie, 2/3's of it is still being loaded in background.
THIS is what I'd like to do, but again, keeping the percentage amount going
to 100% (which will equal roughly 35% of the total file size), even though
100% isn't really loaded. That way, the "loading amount" will go by quicker,
and the viewer won't (hopefully) get fed up and leave.

Does that all make sense and is it possible.

Here is my code for the ...BWshortTest2.html link

Thanks again.

Alexis



bytes_loaded = Math.round(_root.getBytesLoaded());
bytes_total = Math.round(_root.getBytesTotal());
percent_loaded = (bytes_loaded/bytes_total)*100;
_root.enlarger = percent_loaded;
_root.loadText = Math.round(percent_loaded)+"% Loaded";
if (bytes_loaded == bytes_total) {
_root.gotoAndPlay(6);
}
Re: preloader code help Laiverd.COM
4/3/2004 2:34:41 AM
// max width of loading bar bar_mc
var barFullWidth = bar_mc._width;
// amount to load before playing
var percentToLoad = 50;
// total bytes to load
var totalBytes = this.getBytesTotal();
// required bytes to load
var bytesToLoad = totalBytes * (50 / 100);
// create a loop
_root.onEnterFrame = function() {
// get bytes loaded, display as text and progress loadbar
bytesLoaded = this.getBytesLoaded();
percent = Math.round((bytesLoaded / bytesToLoad) * 100);
percent_txt.text = percent +"%"
bar_mc._width = barFullWidth * (percent/100);
// check if already the required amount of bytes was loaded; if so > play()
if (bytesLoaded >= bytesToLoad) {
play();
delete onEnterFrame;
}
};
// we loop on this frame, so we stop here
stop();

Example file at:
http://home.hccnet.nl/john.mulder/flash/load_partial_display_100.zip
(Version FlashMX 2004) Just let me know if you have MX and can;t deal with
this file.

John



--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

Re: preloader code help AlexisNeel
4/3/2004 8:06:36 AM
John,

Thanks. I tried to open your file with MX 2004 professional and regular MX
and I got the message bad file format. I have no idea why.

I'm going to try and see if I can understand your code first, and if I could
use the example, I can ask you then...I don't want to put you out.

Thanks
Re: preloader code help Laiverd.COM
4/3/2004 12:39:47 PM
Just downloaded and opened the file without any problem. Opening files with
a pirated copy of FMX2004 has been reported to cause the error you describe.
Anyway: I have uploaded an MX version of the file. Just try again. If it
doesn't work and yours is not a pirated copy, send me a mail through my
website and I'll send it to you by mail. Otherwise I hope you can figure out
the code.

http://home.hccnet.nl/john.mulder/flash/load_partial_display_100.zip (MX
version this time ;-)

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

Re: preloader code help AlexisNeel
4/4/2004 11:52:25 AM
John,

Thanks for the MX version. I guess my MX 2004 must be a copy...it came
installed on the system I bought so I have no real way of knowing. The few
times I have tried it, I haven't liked it...I'm not a professional and it seems
geared specificly towards them. I prefer to use 5 or MX...its a bit more user
friendly for us code challenged users.

As for your code, I'm still trying to decifer what you have that will apply to
my specific need. The big thing is that I haven't gotten the "loaded amount"
in percentage to show up at all, compared the the sample I posted above.
Again, except for the fact that where I am now loads completely instead of just
33%, or so, of the total amount, is my only problem.

This is however a great learning, and entrance to, more advanced codeing than
I've done before. Its frustrating because it seems like to get the answer its
a simple math problem, but then applying the necessary code to bring it all
together is the challenge, for me. Code imparred you know.

Thanks again for your help.

Alexis
Re: preloader code help Laiverd.COM
4/4/2004 2:06:51 PM
Could you state the specific question(s) you still have, or things that
don't work? The code is not too complex, so it shouldn't be hard for me to
explain. For the percentage to be displayed; the code expects a textfield
with the instancename 'percent_txt'; be sure that you have that for
instancename (in the properties panel), not for variable.

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

AddThis Social Bookmark Button