-
AS2 | Preloader issues...
Hi everybody, I just realized, that my preloader isn't actually working, and all thanks to trying to load the page on a PC with quite slow internet... The story is following - my preloader animation plays, but only after the whole movie is loaded, cuz I noticed a huge delay before the preloader was actually played... And then I used that flash speed testing thing (sorry, but I don't know how it's called) and it proved my theory... 
That's the code on 1-st frame, where preloader is:
Actionscript Code:
stop(); var loaded:Number = getBytesLoaded(); var total:Number = getBytesTotal(); var percent:Number = Math.floor((loaded*100)/total); if (loaded == total){ gotoAndPlay (2); }else{ _preloader.gotoAndPlay(percent); //loadBar.percentage.text = percent; }
And preloader itself has
on it's frame 100.
Can anybody tell me, where is my mistake?
Last edited by oojustinoo; 03-15-2010 at 10:15 PM.
-
Flash/Flex Developer
Well I've never been great at preloaders, but it appears that your preloader and your movie are one in the same. When I use a preloader, it is separate from the actual movie I am loading. For instance, I use what I like to call a "base" page. This page acts as the container for all other movies and contains the code for the preloader.
The base page loads completely then I have a function that immediately starts loading the main page. My preloader displays the loading process of the main page without delay because the preloader (base page) is already loaded. I load the main page into an empty movieclip on the stage, so I am NOT replacing my base page, just loading a new page into it.
Does that make sense?
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
-
Flash/Flex Developer
I don't want you to misunderstand, it isn't a mistake. You code is running correctly, but since the preloader isn't completely loaded when you want it to be, it can't run as a preloader. The best part about making a base page, is you're not losing all the work you've done. You are simple separating the preloader from the main page.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
Well yes, if you preloader is in frame 1 and your movie is in frame 2, how can the preloader have anything ? If the preloader is in frame 1, then that's all there should be... with the rest of the movie in frame 2 and on.
Here's working code for a preloader that uses a mask to uncover an image as a cue to the percent of the file loaded. Perhaps you can adapt parts as needed:
Code:
stop();
mask_mc._height = 1;
this.onEnterFrame = function():Void {
var loadedData:Number = this.getBytesLoaded();
var allData:Number = this.getBytesTotal();
var percent:Number = Math.round(loadedData/allData*100);
mask_mc._yscale = percent;
if (loadedData>=allData) {
gotoAndStop(10);
delete this.onEnterFrame;
}
};
Best wishes,
Eye for Video
www.cidigitalmedia.com
-
Well, my preloader is a separate movie clip in the library, that is placed on frame 1, but that preloader clip itself has 100 frames.
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
|