Jump to content


Preloader problem


  • You cannot reply to this topic
11 replies to this topic

#1 Flanders

    Young Padawan

  • Members
  • Pip
  • 53 posts
  • Gender:Female
  • Location:Gilbert, PA
  • Interests:web design, graphic design, photography, philosophy, politics, myst, the sims, maple story

Posted 23 July 2007 - 07:41 PM

All right, I've been trying to figure this out for awhile now...I decided I finally need to ask for help...

I created a preloader for our website, http://www.digitalzone1.com, but for some reason it only shows after it's loaded 75%. I can't really figure out why this is, other than the fact that I've never had much luck with preloaders.

If anyone could make a suggestion, I'd really appreciate it. The site is up for an award come September, and I want it in the best shape possible for when the voting starts in August. ^^ That, and I can't stand that it doesn't work right.

Here's the ActionScript I'm using:

bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
	this.gotoAndPlay(3);
}

Thank you! :biggrin:

#2 lysol

    Young Padawan

  • Members
  • Pip
  • 140 posts
  • Gender:Male
  • Location:Washington, DC

Posted 23 July 2007 - 09:36 PM

could you PM me your .FLA file?

#3 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 23 July 2007 - 09:47 PM

You should use an initial preloader swf that contains nother other than the preloaders graphics and the background, then use that file and the MovieClipLoader class to load up your main swf. That way the preloader will show up as soon as all of its assets have loaded, but it won't try and load all the classes and stuff for the swf on the first frame.

I also suggest only using a single frame preloader. Just use an onEnterFrame = function(){} And put your code in that on the first frame rather than a two frame loader. Ive always had problems with those.

If you use the first option, it'll kill any code that uses _root, but you shouldn't be using that much anyways.

#4 lysol

    Young Padawan

  • Members
  • Pip
  • 140 posts
  • Gender:Male
  • Location:Washington, DC

Posted 23 July 2007 - 10:15 PM

try this. works for me everytime.

onClipEvent (load) {
 total = _root.getBytesTotal(); 
}
  onClipEvent (enterFrame) {
 loaded = _root.getBytesLoaded(); 
 percent = int(loaded/total*100);
 perc = ""+percent+"%";
 gotoAndStop(percent);
 if (loaded == total) {
  _root.gotoAndPlay(2);
 }
}

Edited by Lopezt, 23 July 2007 - 10:15 PM.


#5 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 24 July 2007 - 07:35 AM

View PostLopezt, on Jul 23 2007, 11:15 PM, said:

try this. works for me everytime.

onClipEvent (load) {
 total = _root.getBytesTotal(); 
}
  onClipEvent (enterFrame) {
 loaded = _root.getBytesLoaded(); 
 percent = int(loaded/total*100);
 perc = ""+percent+"%";
 gotoAndStop(percent);
 if (loaded == total) {
  _root.gotoAndPlay(2);
 }
}

I wouldn't recommend using _root, onClipEvent() or on() in your code. It's bad practice.

#6 lysol

    Young Padawan

  • Members
  • Pip
  • 140 posts
  • Gender:Male
  • Location:Washington, DC

Posted 24 July 2007 - 08:48 AM

^sure. What would you recommend?

#7 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 24 July 2007 - 09:03 AM

Use

this.onEnterFrame = function(){
//some code here
}

And reference movie clips using _parent's and the instance name of the target clip. Best practice is to put all your code on one frame, rather than putting it on instances of movie clips on the stage.

#8 lysol

    Young Padawan

  • Members
  • Pip
  • 140 posts
  • Gender:Male
  • Location:Washington, DC

Posted 24 July 2007 - 12:22 PM

Interesting...thanks for the tip.

#9 Flanders

    Young Padawan

  • Members
  • Pip
  • 53 posts
  • Gender:Female
  • Location:Gilbert, PA
  • Interests:web design, graphic design, photography, philosophy, politics, myst, the sims, maple story

Posted 24 July 2007 - 12:44 PM

View PostPax, on Jul 23 2007, 10:47 PM, said:

You should use an initial preloader swf that contains nother other than the preloaders graphics and the background, then use that file and the MovieClipLoader class to load up your main swf. That way the preloader will show up as soon as all of its assets have loaded, but it won't try and load all the classes and stuff for the swf on the first frame.

I also suggest only using a single frame preloader. Just use an onEnterFrame = function(){} And put your code in that on the first frame rather than a two frame loader. Ive always had problems with those.

If you use the first option, it'll kill any code that uses _root, but you shouldn't be using that much anyways.

So what I should do is isolate the preloader in its' own .swf and import that into the main .swf? I'm sorry if I'm not grasping this; again, I'm pretty new to Flash.

#10 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 24 July 2007 - 03:44 PM

Got the isolation part right, but the other way around.

Say you have a file called preloader.fla and preloader.swf. It is the preloader.swf that you would embed into your html page. This preloader.swf would load your main site swf into a movieclip within preloader.swf.

#11 Flanders

    Young Padawan

  • Members
  • Pip
  • 53 posts
  • Gender:Female
  • Location:Gilbert, PA
  • Interests:web design, graphic design, photography, philosophy, politics, myst, the sims, maple story

Posted 25 July 2007 - 02:32 PM

View PostPax, on Jul 24 2007, 04:44 PM, said:

Got the isolation part right, but the other way around.

Say you have a file called preloader.fla and preloader.swf. It is the preloader.swf that you would embed into your html page. This preloader.swf would load your main site swf into a movieclip within preloader.swf.

Okay, I've created two separate files...how would I go about having the preloader actually the call the main site? I'm having trouble figuring out how to sync up the two elements...

#12 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 25 July 2007 - 03:06 PM

Look for info on the moviecliploader class. Use that with your progress bar to load the main site.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users