Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : Please Help. Preloader script trouble!


exor?
5/10/2004 8:54:13 PM
hello all, hear my plea please.

my first preloader gave trouble so i decided to load my main movie as an
external .swf file. so now, the animation play, and the preload bar starts from
0 bytes. the way i wanted it. but now, it does not play the remaining animation
when i ask it to. this is what the animation looks like [NOTE: this swf is
preloading itself, the old one i was using, but this is what i want the
animation to look like]
[L=DEMi]http://www.geocities.com/uends/newWebIndex.html[/L]

for the setup i have now, the first part of the animation plays fine and the
preloader starts at 0, but the animation after get's stuck. the load and after
animation are on one timeline since i loaded an external file [the above have 4
scenes, the first animation, the load, the last animation, then the main page].
this file only has 2 scenes, the first animation, then "the load, last animate
and main page" on the second scene. can someone please help me. here is my code

[b]code[/b]

//::load external .swf file::
loadMovie("external.swf", container);

onEnterFrame = function(){
loadedBytes = Math.round(container.getBytesLoaded());
totalBytes = Math.round(container.getBytesTotal());

bytePercent = loadedBytes/totalBytes;

//::resize loadBar and display percentage::
_root.loadBar.loadBar._width = Math.round(bytePercent * 100);
_root.loadBar.dispText.text = "[ " + Math.round(bytePercent * 100) + "% ]";

if (loadedBytes == totalBytes){
gotoAndPlay("sFrame"); [b]//this works, but it stops at frame 5 of 15
instead of tweening the way it should[/b]
}
}
//::end of line::
stop();


[b]visual setup[/b]

timeline from frame one
|1234|567"sFrame"131415|16| |
|1234|------tween---------->|16| |
|1234|------tween---------->|16| |


the above script goes on frame 1-4, "sFrame" consist of 5-15 and it has 2
tween for the last animation. but it stops at frame 5 and refuses to
continue..... can anyone help me with this problem. thank you very much.

NOTE: the loadBar and loading part of the swf works just fine. everything
loads correclty on all test done. the problem is getting it to play all the way
after the frame jump.
exor?
5/11/2004 7:57:55 PM
ezmobius1
5/12/2004 2:52:44 AM
Heres my code that I use for all of my preloaders and it works like a charm
every time!
If you want a .fla file of a working version of this preloader email me at
ezmobius1@mac.com and I'll send it to you

////action on frame 1
bytes_loaded = Math.round(_root.getBytesLoaded());
bytes_total = Math.round(_root.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.loadBar._width = getPercent*100;
_root.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
_root.gotoAndStop(3);
}

///////you can also gotoAndPlay(3) depending on how your animation is set up
on frame 3

///// action on frame 2
gotoAndPlay(1);


you need a movie clip called loadbar that is a colored bar maybe 15 pixels
tall and 100 pixels long and underneath it you can make a dynamic text box and
in the properties panel give it a var name of loadtext.

Then start the rest of your movie on frame 3. the loadbar will grow from
nothing to 100 pixels long while the dynamic text field reads from 0% to 100%.
as soon as bytes_loaded == bytes_total your movie will jump to frame 3 and play
from there!
Hope this helps you out!
AddThis Social Bookmark Button