;

PDA

Click to See Complete Forum and Search --> : Customised preloader


sdg_uk
04-02-2005, 06:22 PM
I've been trying to find a simple entry on the board that explains how to write a custom pre-loader for KM. I have a file with a large sound content and wanted a simple animation at the start. I couldn't work out how to use the KM preloader option to load a .fun file so I was following an example that was for Macromedia Flash MX and couldn't get it to work for KM.

The posts I found seemed to say it wasn't possible / was quite difficult to write a preloader, but I think I've written my own version (you can see it here (http://www.stuartandnicola.com/html/chemeng_reunion.html)) The trick seems to be that in Koolmoves you need to set the export settings to "Put image and sound data just before they are needed" It was this key step I've not seen referred to anywhere?

If you don't do this bit then it tries to load all the sound before the movies starts, so the preloader gets skipped.

Apologies if I am repeating something that everybody else already knows, but I couldn't find a post that explained it to me clearly on this board, hence my post.

All I have is a frame one with three objects on (the progress bar, text and rotating graphic). In frame two I have the same objects and this script:

percent = Math.Floor( getBytesLoaded() / getBytesTotal() * 100);

barmc._xscale = percent;
txtLoad.text = percent + "%";

mcLoad._rotation = mcLoad._rotation + 5;

if ( percent<99 ) {
gotoAndPlay(1);
}So I'm using the script to rotate my loading message. The bar scaling bit is cobbled together from the original KM loader itself and it's similar to code I saw in the MX example. It all seems to work quite nicely.

If someone on the board thinks my description above is wrong then feel free to correct it - I'm just a learner :)

Please post if you find the preloader doesn't work - it's only had limited testing (ie me) so any feedback would be appreciated.

FLASHPULSE
04-03-2005, 12:03 AM
Nice work!

For a small script it seems to work great. Although I have an idea of how you did this, would you mind posting a fun file similar to this so I can study it.

Also, what if the percent isn't greater then 99, shouldn't there be an error check? Like if percent is less then 99, then reloop. Maybe it's not needed, I know nothing of creating custom preloaders.

sdg_uk
04-03-2005, 07:48 AM
I'll add the .fun file tonight (I'm in work today, on a Sunday :() Although there is nothing more to it than the two frames and few lines of code described above.

The percent<99 code should work as getBytesLoaded must always eventually reach getBytesTotal, so the percent value must always achieve 100. Hence the preloader loops around frames 1 and 2 (the script is on frame 2) until the movie is practically completely loaded. When the test fails then the movie continues and plays from frame 3.

Also, I was browsing the board some more and found this from necromanthus

All shapes are exported in the first "user" keyframe,no matter what are your export settings.
The "Loading Considerations" are working for images and sounds only !
For this reason, a custom preloader (containing at least one shape) must wait for them to be downloaded.
The unique solution is to generate preloader's shapes.If I read this right then my preloader won't start until all shapes are loaded, but it will run while the remaining sound and images are loaded. Given I wanted the preloader for a file where the size was dominated by the audio content then I guess this isn't an issue.

However, would this mean that for a movie with a significant quantity of shapes then this preloader might not work as intended? It wouldn't start up until most of the loading was done, which would defeat the object of it?

sdg_uk
04-03-2005, 07:53 AM
PS - I just tested my page from work and I don't see the percentage counting up. When I view the page at home I see 24%, 25%, 26% etc. At work I just see the rotating text and the progress bar. Why would that be? If anyone else has watched this example do the numbers appear for you? :confused:

Bob Hartzell
04-03-2005, 08:49 AM
On our support page under Tutorials - Preloader is a link.

sdg_uk
04-03-2005, 10:27 AM
I'd spotted the tutorials, but neither of them let me achieve the effect I wanted (I had it in mind I really wanted rotating text!). I'd spotted necromanthus' example on this board too and he says it avoids the "shapes load first" issue, but I couldn't see how to adapt it to get the specific effect I wanted.

I've noticed that if you ask KM to add a preloader there is the option to specify a preloader .fun file, but I've not managed to make my loader work with that and I can't find a description of how it is to be used (or maybe I didn't look in the right place?)

In the meantime, here's the file for my loader.

FLASHPULSE
04-03-2005, 01:16 PM
Originally posted by sdg_uk
PS - I just tested my page from work and I don't see the percentage counting up. When I view the page at home I see 24%, 25%, 26% etc. At work I just see the rotating text and the progress bar. Why would that be? If anyone else has watched this example do the numbers appear for you? :confused:

Yeah, I saw the numbers just fine. I wonder why you didn't at work, strange. :confused:

sdg_uk
04-03-2005, 01:30 PM
I've done some more experimenting and have now got my custom preloader to "add on" to my movies using the KoolMoves loading message option. I saved my loader as .fun file called Loader, containing just the two frames and script that make the loader work.

Then in KM I made my test movie, with sound, and told KM to use a loading message but specified my .fun file rather than specifying text. I turned off the option for a progress bar (because my loader includes it).

Hey presto, it works, but only if the export settings are set to "Put image and sound data just before they are needed". So now I have my own loader than I can bolt on to any movie with no effort :)

Hope others find this thread helpful!

FLASHPULSE
04-03-2005, 11:45 PM
Thanks for the information. I'll give this a try soon. :D