dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: another preloader question

  1. #1
    Junior Member
    Join Date
    Sep 2003
    Location
    atlanta
    Posts
    22

    another preloader question

    this is the code i am using for a preloader named progressbar and a dynamic textfield name rate. The preloader moves, but keeps expanding until it runs off the page and the text shows up, but doesn't move from 0% then it jumps to 100%..what is the problem

    stop();
    myInterval = setInterval(preloader, 10);
    function preloader() {
    if (getBytesLoaded()>=getBytesTotal()) {
    play();
    clearInterval(myInterval);
    }
    progressbar._xscale = (getBytesLoaded()/getBytesTotal())*100;

    rate.text = Math.round (getBytesLoaded()/getBytesTotal())*100 +"%";
    }

  2. #2
    Junior Member
    Join Date
    Sep 2003
    Location
    atlanta
    Posts
    22
    ok...i got the text field to work...i just had my parenthasis in the wrong place...now how do i get the preloader image to stop expanding off the page?

  3. #3
    Member
    Join Date
    Aug 2003
    Location
    Dryden, ON - Canada
    Posts
    71
    I can't really tell for certain but your code looks right. Perhaps try using this code:

    stop();
    myInterval = setInterval(preloader, 10);
    function preloader() {
    // get percent of movie loaded and round to the nearest number
    percent = Math.floor((getBytesLoaded()/getBytesTotal())*100);
    // check to see if movie is fully loaded
    if( percent == 100 ) {
    clearInterval(myInterval);
    play();
    }
    // make sure preloader is graphically displayed as movie loads
    else {
    progressbar._xscale = percent;
    rate.text = percent + "%";
    }
    }

    In the above code, you set percent to the current percentage each time preloader() is called, and at the same time round it up to the nearest number (this should be done everytime anyways so then you aren't using decimals when setting the _xscale.

    Hope this helps, although the code is untested!
    Tyouk

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