views:

256

answers:

2

Hi

currently I'm having some problems with my preloader.

I have an as3 class website with the following code:

public function Website() {

  addEventListener(Event.ENTER_FRAME, PreloaderStart);
 }

 private function PreloaderStart(e:Event):void {
  var bt:int=loaderInfo.bytesTotal;
  var bl:int=loaderInfo.bytesLoaded;
  trace(bl/bt);
  var pt:int=Math.round(100*bl/bt);
  preloaderMC.loadInfo.text="loading "+pt+"%";
  if (bl==bt) {
   removeEventListener(Event.ENTER_FRAME, PreloaderStart);
   PreloaderOnComplete();
  }
 }
 private function PreloaderOnComplete():void {
  trace("loaded");
  buildUI();
 }

I painted my stage black and when I simply run my flash file it traced "loaded" so everything is loaded well and it builds the UI. But when I simulate by pressing ctrl+ enter twice I get a white screen and after about 10 sec. (my swf is 1mb and it simulates at 100kbs) it displays the preloader instantly at 100% and loads my UI. So my text doesn't change from 0% -> 100% but I just get 100% when everything is loaded.

if anyone can help me out, I would be thankfull.

Regards

+1  A: 

Have a look at the first frame with the bandwith profiler. If you've got a lot of things to load, you might to move them on the 2nd frame, and leave as few things as possible for the first frame.

If you look in the bandwidth profiler and simulate a download you should see that the preloader or any content shows up only after the 1st frame is loaded.

You might need to set the actionscript settings' export frame to 2, depending on what classes/components you're using.

HTH

George Profenza
I only have the textbox on my stage. which says: ... % loaded. I load the content once I get into function buildUI() through code
Ayrton
any symbols in the Library with Linkage(class export) setup ?. In the Bandwith profiler, what's the size (in KB) of your first frame ?
George Profenza
that was exactly the problem. I did everything in a document class. Now when I added a new frame, changed the settings to export to frame 2 then evertyhing worked perfectly. Thanks a lot
Ayrton
glad u got it sort it out :)
George Profenza
+1  A: 

If your buildUI call references any other classes (which it probably does), all that code will also be loaded on the first frame.

Assuming you're using Flash and not Flex Builder, your buildUI() call would better be placed on frame 2. And do what George wrote about the Actionscript being exported to frame 2.

frankhermes