A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [F8] music loader progress?

  1. #1
    flash animator guy
    Join Date
    Oct 2006
    Location
    Daly City
    Posts
    219

    [F8] music loader progress?

    Hello there.

    I'm trying to build a progress bar the shows how much of an external mp3 has loaded.

    the bar instance is an mc named "mpBar" , which is nested in a mc named "mcmpb".

    I tried to set the inital _x property to 0, and then have it increment based on getbytsloaded/getbytstotal; but it's not showing working (it starts out in the 100% position).

    My code is as follows

    var nLoadProgressInterval:Number;

    _root.mcmpb.mpBar.setProperty("_root.mcmpb.mpBar", _xscale,0);

    function checkLoadProgress():Void {
    mBytes = _root.sndAudio.getBytesLoaded()/_root.sndAudio.getBytesTotal();
    setProperty("_root.mcmpb.mpBar", _xscale, mBytes);
    }


    and on the button I have a call to the function like this

    _root.track3.onRelease = function():Void {
    nLoadProgressInterval = setInterval(checkLoadProgress, 100);
    }


    Any help here?

  2. #2
    Senior Member
    Join Date
    Apr 2007
    Posts
    161
    Check this in your help files

    Sound.getBytesLoaded method

  3. #3
    flash animator guy
    Join Date
    Oct 2006
    Location
    Daly City
    Posts
    219
    Sound.getBytesLoaded is for streaming an mp3 (according to the help file). My mp3's aren't streaming. They are loaded from an external server, but the must load fully beffore they start.

    I've got the bar to start properly now ("_xscale = 0"). The problem I'm having now getting the bar to expand, showing the progress.

    I'm guessing the function isn't being called properly or is's not passing the data properly to the progress bar.

    Any ideas?

    Thanks

    RSB

  4. #4
    flash animator guy
    Join Date
    Oct 2006
    Location
    Daly City
    Posts
    219
    I tried "_sound.getBytsLoaded" and it doesn't work. The original should work. As I figure it's a problem calling the function or maybe passing the data.

    Any ideas?

  5. #5
    Senior Member
    Join Date
    Apr 2007
    Posts
    161
    Try this:

    var nLoadProgressInterval:Number;

    _root.mcmpb.mpBar._xscale = 0;

    function checkLoadProgress():Void {
    mBytes = _root.sndAudio.getBytesLoaded()/_root.sndAudio.getBytesTotal();
    _root.mcmpb.mpBar._xscale = mBytes;
    trace(mBytes);
    }


    and on the button I have a call to the function like this

    _root.track3.onRelease = function():Void {
    nLoadProgressInterval = setInterval(checkLoadProgress, 100);
    }

  6. #6
    Senior Member
    Join Date
    Apr 2007
    Posts
    161
    Quote Originally Posted by fasco1
    Try this:

    var nLoadProgressInterval:Number;

    _root.mcmpb.mpBar._xscale = 0;

    function checkLoadProgress():Void {
    mBytes = _root.sndAudio.getBytesLoaded()/_root.sndAudio.getBytesTotal() * 100;
    _root.mcmpb.mpBar._xscale = mBytes;
    trace(mBytes);
    }


    and on the button I have a call to the function like this

    _root.track3.onRelease = function():Void {
    nLoadProgressInterval = setInterval(checkLoadProgress, 100);
    }
    forgot to mention you have to add * 100 to your mBytes variable or else the highest number you'll get is 1

  7. #7
    flash animator guy
    Join Date
    Oct 2006
    Location
    Daly City
    Posts
    219
    this worked great, thanks!

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