1 Reply Latest reply on Feb 24, 2011 1:15 PM by yamill3

    getting the percentage of what is seekable

    Zombiecook KochtVorWut

      i have a very simple Application , and want to add a sprite that gets scaled in the percentage of whats being load.
      I have done that with the simple bytesLoaded and bytesTotal But this doenst worked since the percentage doesnt match the seekable percentage.
      So how do i display the "area" that is seekable.
      Or how do i get the percentage of ehat is seekable ?


      My application:


                public function initMediaPlayer( url:String ):void {
                  mps            = new MediaPlayerSprite();
                  mps.width    = stageWidth;
                  mps.height    = stageHeight;
                  mps.resource = new URLResource( url );
                  mps.addEventListener(MouseEvent.CLICK, onClick);
                  mps.mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onTimeChange);
                  mps.mediaPlayer.addEventListener(LoadEvent.BYTES_LOADED_CHANGE, onBytesLoaded);
              private function onClick(event:MouseEvent):void{
              private function onTimeChange(event:TimeEvent):void {
                  progress.scaleX = event.time / mps.mediaPlayer.duration;
              private function onBytesLoaded(event:LoadEvent):void {
                // HERE ?


      Giovanni Beeres

        • 1. Re: getting the percentage of what is seekable

          Giovanni, this is how i get mine.


                  private function onLoadStateChange( e:LoadEvent,trackWidth:Number):void
                      var percent:Number = (e.bytes / mps.mediaPlayer.bytesTotal) * trackWidth;
                      skinControls.trackLoaded.scaleX = percent;
                      //trace( "onLoadStateChange:", percent );


          i made a variable outside called trackWidth, just in case you're wondering. Also make sure to add the coresponding event listener as well.


          Hope this helps!