A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Preloader Code. What is wrong here?

  1. #1
    Senior Member
    Join Date
    Dec 2001
    Location
    Lisbon
    Posts
    281
    Hello,

    i created a code which acts as a preloader to an external movie loaded in level 1. I think, but i am not sure, that the percentage and bytes fields are working. Could you check them?In relation to the Loading BAR, it doesn't scale from 0 to 100. What is
    wrong? My code takes only one frame...here it is:

    _root.loadBarFill._xscale=0;
    // load the external movie into the new movieclip
    loadMovieNum("pt27lamps.swf", 2);
    // check the download status of the external
    // movie once every frame
    this.onEnterFrame = function() {
    // displays the percentage of the movie that has loaded
    _root.loadDisplay.loadPercent = Math.floor(_level2.getBytesLoaded()/_level2.getBytesTotal()*100)+"%";
    _root.loadDisplay.loadBytes = Math.round(((_level2.getBytesLoaded()/1024)*1000)/1000)+"Kb";
    _root.loadBarFill._xscale = _root.loadDisplay.loadPercent;
    if (percent == 100) {
    delete this.onEnterFrame;
    }
    };



    Thanks,
    Miguel

  2. #2
    Senior Member
    Join Date
    Sep 2002
    Posts
    265
    the problem with your loadbar is this:

    _root.loadDisplay.loadPercent = Math.floor(_level2.getBytesLoaded()/_level2.getBytesTotal()*100)+"%";


    here, _root.loadDisplay.loadPercent is equal to a number + a percent symbol... like "45%"


    _root.loadBarFill._xscale = _root.loadDisplay.loadPercent;


    you can't set the scale to a string... "45%"


    to fix this, do

    _root.loadDisplay.loadPercent=Math.floor(_level2.g etBytesLoaded()/_level2.getBytesTotal()*100
    _root.loadDisplay.loadPercentText=_root.loadDispla y.loadPercent+"%";
    _root.loadBarFill._xscale = _root.loadDisplay.loadPercent;

    And have your dynamic text show "_root.loadDisplay.loadPercentText"

  3. #3
    Senior Member
    Join Date
    Dec 2001
    Location
    Lisbon
    Posts
    281

    Smile Thanks

    I just made it work.
    Stupid mistake which i didn't notice.

    Thanks for your help.
    Miguel



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