PDA

View Full Version : Please check this preloader script!!!


Jim Curtis
01-17-2007, 06:33 PM
Please can somebody check this preloader script?
My flash file scene is 1.170kb, and it's the only file combined with dreamweaver to give me my homepage.(nothing else is on the page)

When viewed on line (broadband) the preloader bar loads in under 10 secs and then the homepage opens and plays, the big problem is, the contained flash file scene is very slow at playing meaning the music contained within it, is very out of sync! Please help me resolve it!
Here is the script:

onClipEvent (load) {
total = _root.getBytesTotal();
}
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
percent = int(loaded/total*100);
text = percent+"%";
gotoAndStop(percent);
if (loaded == total) {
_root.gotoAndPlay(2);
}
}

ps the initial flash file scene contains 332 items, is this to many?, and what does linkage mean???:confused:
Thanks Jim.

wvxvw
01-17-2007, 09:09 PM
on (event) and onClipEvent are deprecated since Flash6. Although, there's nothing wrong about your code, it's better to use movieClipLoader class to load whatever you might need.
332 isn't to many, however the overall size of your SFW is tremendously huge =) The average web site made in flash is 100-200Kb. Good flash site may be even 10-50Kb.
Linkage is an export identifier you assign to the items in the library so you'll be able to access it through ActionScript.

Jim Curtis
01-17-2007, 09:33 PM
Thanks for that, as I don't know actions from behaviors in code language, is there any chance you could give me the code that would replace this old code so I could paste it in?

Thanks Jim

wvxvw
01-20-2007, 11:01 PM
21034

Look in attachment =)

jlfximedia
01-20-2007, 11:44 PM
Nice and clean code.

What does the add listener do? Usually, I would have the rest of the code within the "onComplete" function. But you have it outside that.

I know your code is the newer, right way to do it and just want to learn.

jleo
01-21-2007, 07:28 AM
How do you use the preloader xvxvw provided? Using a gotoandPlay(2) is easy enough in the original example.

Would you load the next frame instead of that URL?

wvxvw
02-01-2007, 10:15 PM
AddListener() is a function that 'subscribes' another object to the events produced by some other function. So that when the event happens object will run proper function to handle it.
In case of MovieClipLoader these events may happen:
onLoadComplete
onLoadError
onLoadInit
onLoadStart
to handle them you have to have a listener-object (not necessary empty and new one =). It may be the _root object or even _global object. And you have to specify the function it has to run after even will happen.