1 Reply Latest reply on Jun 27, 2006 4:56 AM by Newsgroup_User

    getBytesLoaded from loadSound

    stuart1231
      Hi,

      I am new to actionscript (as most of these posts start) and I am stuck,

      I would like to get the percentage of the loadSound function, I know how to work out the percentage from the getBytesLoaded and getBytesTotal, but I cant get the actual numbers in the first place :(

      Here is my current code (simplified)

      MovieClip.prototype.songStarter = function(file, name) {
      this.sound_obj.loadSound(file, true);
      this.onEnterFrame = function() {
      if (this.sound_obj.position>0) {
      delete this.onEnterFrame;
      this._parent.display_txt.text = name;
      this._parent.display_percnt = trace(this.sound_obj.getBytesTotal());

      } else {
      this._parent.display_txt.text = "loading...";
      this._parent.display_percnt = trace(this.sound_obj.getBytesLoaded());
      }
      The mp3 file loads from an XML file, but im sure the trace(this.sound_obj.getBytesLoaded()); is wrong

      Note the percnt spelling is wrong on purpose.

      Any help would be amazing!

      Stuart
        • 1. Re: getBytesLoaded from loadSound
          Level 7
          Erm?... What is "this._parent.display_percnt =
          trace(this.sound_obj.getBytesLoaded());" supposed to do?...

          If that should be a number from 0 - 100, something like this would do the
          trick, I'd guess:

          if (this.sound_obj.getBytesTotal()>0) {
          this._parent.display_percnt = ((this.sound_obj.getBytesLoaded() /
          this.sound_obj.getBytesTotal())*100);
          } else {
          this._parent.display_percnt = 0;
          }
          // And maybe something like:
          this._parent.display_txt.text = "loading..."+this._parent.display_percnt+"%
          complete...";

          Eric


          "stuart1231" <webforumsuser@macromedia.com> wrote in message
          news:e7r1qg$8c1$1@forums.macromedia.com...
          > Hi,
          >
          > I am new to actionscript (as most of these posts start) and I am stuck,
          >
          > I would like to get the percentage of the loadSound function, I know how
          > to
          > work out the percentage from the getBytesLoaded and getBytesTotal, but I
          > cant
          > get the actual numbers in the first place :(
          >
          > Here is my current code (simplified)
          >
          > MovieClip.prototype.songStarter = function(file, name) {
          > this.sound_obj.loadSound(file, true);
          > this.onEnterFrame = function() {
          > if (this.sound_obj.position>0) {
          > delete this.onEnterFrame;
          > this._parent.display_txt.text = name;
          > this._parent.display_percnt = trace(this.sound_obj.getBytesTotal());
          >
          > } else {
          > this._parent.display_txt.text = "loading...";
          > this._parent.display_percnt = trace(this.sound_obj.getBytesLoaded());
          > }
          > The mp3 file loads from an XML file, but im sure the
          > trace(this.sound_obj.getBytesLoaded()); is wrong
          >
          > Note the percnt spelling is wrong on purpose.
          >
          > Any help would be amazing!
          >
          > Stuart
          >
          >