A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: Help with preloader

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    259

    Help with preloader

    Hi guys!
    I made a preloader for my site, and it's working.
    Now I just need to fine-tune it to my liking and I'm not sure how to do it.
    I need my preloader to do two things that it isn't doing:
    - Force showing all the numbers from 0 to 100(It stops earlier, depending on user's connection);
    - Show the preloader immediately once the user enters the site(the preloader only appears after reaching 20% loaded or so).

    I think this should be easy for some people here. Thanks in advance!

    If you need to see it check it out:
    www.drummerfreak.cjb.net
    Up the Irons!!

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    where is yo upreloader located?..and what is it trying to preload? is it an external.swf thats ts trying to get the percentage of?

  3. #3
    Senior Member
    Join Date
    Nov 2000
    Posts
    259
    No, the preloader is a scene, and the site is in the next scene...
    The preloader is a Movie Clip with this code:

    Code:
    onClipEvent (load) {
    	tot = _root.getBytesTotal()/1000;
    	total = Math.round(tot)+"K";
    }
    onClipEvent (enterFrame) {
    	down = _root.getBytesLoaded()/1000;
    	download = Math.round(down)+"K";
    	bytes = (_root.getBytesTotal()-_root.getBytesLoaded())/1000;
    	bytesleft = Math.round(bytes)+"K";
    	per = _root.getBytesLoaded()/_root.getBytesTotal()*100;
    	percent = Math.round(per);
    }
    Up the Irons!!

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    259
    bump!
    Up the Irons!!

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    hi..sorry..on my way out (home form work)

    you can try to export your movie / linkage to be in first frame..or for AS (not sure of the options)

    the reason you preloader is NOT showing up immediately is because the preloader is IN the same file you trying to preload.... by default a certian amount of a flahs movie HAS to be downloaded before ANYTHIGN can be shown (which inclueds your preloader)..so when it CAN finally display something...you have already downloaded 20% (which is what your preloader reflects when it becomes visible)

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Posts
    259
    hm...
    But still, there should be a way to make the counter start from 0 even when it's loaded more than that...even it if appears racing from 0 to 20, I don't care as long as it shows all numbers from 0 to 100...
    Up the Irons!!

  7. #7
    Senior Member
    Join Date
    Nov 2000
    Posts
    259
    Or maybe some kind of speed average function to make it progress smoothly, using the same time interval from 0 to 100?
    Up the Irons!!

  8. #8
    Senior Member
    Join Date
    Nov 2000
    Posts
    259
    Bump!
    Up the Irons!!

  9. #9
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    _root.getBytesLoaded

    your checking to see how much is loaded of your total....unless you want to subtract.

    did you try to export in first frame for AS?

  10. #10
    Senior Member
    Join Date
    Nov 2000
    Posts
    259
    I just want the % to go from 0 to 100 without skipping any numbers...
    Up the Irons!!

  11. #11
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    have you tried the things mentioned here? and just because you may not SEE all the numbers..doesnt mean they didnt show...its as fast as it loads.

  12. #12
    Junior Member
    Join Date
    Dec 2004
    Posts
    27
    You might be able to use a easing script, make the loaded bytes the new x coordinat and have the bar move to that point. Are you usine a change in _x for the bar or a change in scale? Either way, and easing function like

    var cX:Number = this._x;
    var nX:Number = per;
    onEnterFrame=function(){

  13. #13
    Junior Member
    Join Date
    Dec 2004
    Posts
    27
    sorry lets continue.

    onEnterFrame=function(){
    var distX:Number=(cX-nX)*0.9;
    if(this._x!=nX){

  14. #14

  15. #15
    Junior Member
    Join Date
    Dec 2004
    Posts
    27
    sorry lets continue.

    onEnterFrame=function(){
    var distX:Number=(cX-nX/3)*0.9;
    if(this._x!=nX){
    this._x+=distX;
    }else{
    this._x=nX;
    }

    Its pretty simple, you can make it more complicated if you want.

    If you want the load bar to remain for a short period there was an example in the actionscript bible that used setInterval instead of onEnterFrame and uses conditional statements that start a counter once the percentage has reached 100%, when the counter equals a certain value the movie jumps forward on the timeline to the next section containing all the homepage.

    Actually there are sooooo many ways to do a preloader that you need to do some experimenting to find out what works best for your site. You can also use the progress bar component.

    Good luck.

  16. #16
    Senior Member
    Join Date
    Nov 2000
    Posts
    259
    Actually there is no progress bar...I just want the numbers...
    Up the Irons!!

  17. #17
    Junior Member
    Join Date
    Dec 2004
    Posts
    27
    What if you put the preloading script on the second frame of the preloader mc and then create a variable that will store the number of bytes loaded at that stage and then deduct them from the total bytes when you are doing your percentage calculations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center