-
preloader takes forever to show up--why?
I have a preloader (as per a Flashkit tutorial....) set up on the first two frames of my main timeline.
first frame script is:
percent = Math.floor(getBytesLoaded()/getBytesTotal()*100);
myOutput.text = percent + "% is loaded";
second frame script is:
if (percent == 100){
gotoAndStop(3);
}else{
gotoAndPlay(1);
}
"myOutput.text" is a dynamic text box and, yes, I did remember to give it the "myOutput" instance name.
The problem is the preloader isn't showing up til about 90% or so and there's just a big blank buncha nuthin' there for 20 seconds. The site is a multimedia documentary project with some pretty serious file size so I'd expect long downloads but I'd like the preloader (obviously) to be there in the meantime. Any ideas why this is goin on? It is inside a dreamweaver wrapper.
site is: www.unc.edu/~bradhorn/Missy/Missy.htm
(individually-loaded .swf's within the movie have the same dang problem)
I should say that I am not 100% familiar putting stuff online so I could've done several things wrong. But it works fine on my own machine, jugs bug out once online.
help! and: thanks!
bread
-
Math.Floor rounds the integer down.
So.. It will only show up when it is %100 loaded.
Try getting rid of Math.Floor, and use:
Math.Round just before getBytesLoaded and getBytesTotal
Last edited by Scorpion990; 04-21-2004 at 08:32 PM.
-
Senior Member
your preloader looks ok, the problem is probably being caused by most of your movies content being downloaded in the first frame. stuff that uses linkage, eg sounds played using the sound objects attachSound method are by default downloaded before all other content (including the preloader itself).
the easiest solution to this is to use an external preloader (a preloader in a separate file to the rest of your content) this allows the preloader to be loaded immediatly, without all the overhaed of the main movie. then once the preloader movie is started it can begin the download of your main movie.
to create the preloaded make a new movie, in frame 1 place your textfield (instance name myOutput) and add the frame actions,
code:
loadMovieNum("filename.swf", 1); // where filename.swf is the filename of your main movie
this.onEnterFrame = function() {
var percent = Math.round(_level1.getBytesLoaded() / _level.getBytesTotal() * 100);
myOutput.text = percent + "% is loaded";
if (percent == 100) {
_level1.play();
this.gotoAndStop(2);
delete this.onEnterFrame;
}
};
stop();
in frame 2 of this movie leave a blank keyframe.
now in your main movie the preloader code can be removed and instead you can just have a stop(); action on frame 1.
-
sweet! That makes perfect sense. Yes, I have two large audio files that are loading using attachSound, you are absolutely right on.
Can you tell me a couple things, though, about how exactly I should set up this new, preloader-only movie--same frame rate? Same bg color? Do I need to line up registration points so the loading .swf goes to the right place? Anything else that might give me prob's?
Thanks much, Catbert303, you always know what's going on.
-
Senior Member
Hi,
when you create your preloader file you should use the same frame rate and dimensions as your main movie.
the only other thing I can think of that you should look out for is your sound objects. when in a loaded movie they need to be given a target otherwise the sound won't play. so if you have a line a little like this to create the object,
code:
mySound = new Sound();
in order for this to work when the movie is loaded into the preloader this would need to be changed to,
code:
mySound = new Sound(this);
-
hi. Your last tip helped me with something I've been trying to figure out for days now ("this"--now I don't have to load the audio twice thank god!).
Using the idea you gave me I am encountering problems with the loaded .swf (which is actually just a child, it's not the *main* movie) showing up in the upper left-hand corner of the stage when that's not where I want it. I am assuming this is because the preloader is a 'loadMovieNum' operation and that's where 'loadMovieNum' puts things.
I tried playing around with doing just 'loadMovie' but the previous problem happened--the preload script didn't pop up until the audio had loaded. Is there a way to do the preloader with 'loadMovieNum' but that I can direct the loaded .swf to the spot that I want? Or with just 'loadMovie' so I can put it exactly where I want it to go?
Thank you.
-
It seems we have a very similar problem; I have uploaded without difficulty previously, but this time I have sound and that is probably why the loading bar gets stuck, have put in a message but it is now on page 2, it is called "viewing uploaded Flash" have had no replies, so if you have any suggestions as to how to make it work, please tell me, I am afraid all the info given to your message sounds horribly complicated! also I wonder if it is possible to make that white rectangle at the beginning disappear or at least make it the same colour as the background; my Flash is at: http://www.users.bigpond.com/matild...hday%20card.htm
-
Hurrah! tried yet something else and it now works, you really need patience and perseverance for this Flash thing, but gee it is addictive; I had the sound layer starting from the very 1st frame, moved it 2 up and now it loads like a charm; I am really pleased as I need to send that birthday card in 2 days; might start on the Xmas one straight away, just in case!
-
Senior Member
Hi,
if you need to place the movie away from the top corner you could modify the preloader code like this,
code:
loadMovieNum("filename.swf", 1); // where filename.swf is the filename of your main movie
this.onEnterFrame = function() {
var percent = Math.round(_level1.getBytesLoaded() / _level.getBytesTotal() * 100);
myOutput.text = percent + "% is loaded";
if (percent == 100) {
// re position the loaded movie ------
_level1._x = 50;
_level1._y = 25;
// -------------------------------------------
_level1.play();
this.gotoAndStop(2);
delete this.onEnterFrame;
}
};
stop();
-
hi catbert et all.
this preloader script is not working quite right no matter how many variations I try because: the preloader and the loading .swf are occupying the exact same piece of the stage--therefore when the main .swf begins to load it simply covers up the preloader placeholder underneath it. I kind of got around that by setting up the preloader with "loadMovie" ("rather than loadMovieNum") function:
personal_btn1.onRelease = function() {
loadMovie("personal_preload.swf", timeline_mc);
timeline_mc._alpha = 1;
}
And then the preloader has the same "loadMovieNum" function that you specified with your 1st script. But my solution is pretty lame because the only thing that's really happening is that the "myOutput" dynamic text box stays on-screen because there's no "unloadMovie" action telling it to go away (dynamic text boxes seem to stay on-screen unless their parent movie is specifically unloaded). I know this is the case because other things (a border and entertaining movieclip) on the same frame as "myOutput" don't appear while the movie is loading.
I tried sticking some alpha-altering script in the preloader script:
loadMovieNum("personal_preload.swf", 1);
this.onEnterFrame = function() {
var percent = Math.round(_level1.getBytesLoaded() / _level1.getBytesTotal() * 100);
myOutput.text = percent + "% is loaded";
*----> _level1._alpha = 1;
if (percent == 100) {
_level1.play();
*----> _level1._alpha = 99;
this.gotoAndStop(2);
delete this.onEnterFrame;
}
};
But that did nothing--same prob. Try going to:
www.unc.edu/~bradhorn/Missy/Missy.htm
Click on "The Person" to see this taking place with the script 1/2 functioning and click on "The Process" to see the way I want it to look (it looks good because there's no audio file there to screw up the preload process and all the accoutrements (pretty border, etc) are there).
Any direction ***greatly*** appreciated (greatly!).
Thanks. Brad
-
Senior Member
the movie being loaded needs an empty keyframe on frame 1 with a stop(); action attached to it to prevent it displaying until the preloader is finished (once the preloader finds the movie to be fully loaded it tells it to play).
the preloader also needs an empty keyframe in frame 2 so it can be sent to that frame once it is finished loading the main movie, this hides the preloader once the main movie has started.
note that if your textfield was created using createTextField it won't be removed by going to an empty keyframe, so you would also need to use removeTextField to clear it. eg,
myOutput.removeTextField();
similarly if your preloader uses any dynamically created movie clips (attachMovie, createEmptyMovieClip etc...) these would also need to be removed with actionscript using instanceNameOfClip.removeMovieClip();
-
I love you catbert! You need a raise.
yer lucky yer all the way across the Atlantic or I'd give you a big ol' smooch. Thanks, man!
works like a charm.
-
I have had problems with preloader too, but now it works really well and I use the same over and over, it was a "recipe" from Mitch; it is very simple; I have copied the action script in Word and when I need it I simply copy and paste; this is it:
Frame 1 action
totalBytes = this.getBytesTotal();
loadedBytes = this.getBytesLoaded();
remainingBytes = totalBytes - loadedBytes
percentDone = int((loadedBytes/totalBytes)*100);
bar.gotoAndStop(percentDone);
if (_framesloaded == _totalframes) {
gotoAndPlay(3);
}
Frame 2 actions
this.gotoAndPlay(1);;
-
I had problems with preloader taking ages to show, and then I find out that I used too meny heavy bitmap images in to which it had to load first, lol, that will teach me to do simpler preloaders
-
Hi Bradhorn
What are using to incorporate video into flash?
Are you using Flash MX?
What video compression software are you using?
Thanks
Dale
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|