Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer
    
I only have the textbox on my stage. which says: ... % loaded. I load the content once I get into function buildUI() through code –  Ayrton Dec 22 '09 at 13:02
1  
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 Dec 22 '09 at 14:23
    
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 Dec 22 '09 at 15:00
    
glad u got it sort it out :) –  George Profenza Dec 22 '09 at 15:20

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.