0 Replies Latest reply on Aug 27, 2007 12:56 PM by smaudlin

    Custom flv player works great except for Scrubber (F*)

    smaudlin Level 1
      Everything works great except when I click the loadbar, instead of operating my scrubber script it just stops. Can anyone see a problem with this code? Must be a typo somewhere but I can't find it! Scrubber code at bottom.

      //-------NETCONNTCTION SETUP--------------
      var nc:NetConnection = new NetConnection();
      nc.connect(null);

      //-------NETSTREAM SETUP--------------
      var ns:NetStream = new NetStream(nc);

      ns.onStatus = function(info) {
      if(info.code == "NetStream.Play.Start") {
      progressBar.onEnterFrame = videoUpdate;
      }
      if(info.code == "NetStream.Play.Stop") {
      delete progressBar.onEnterFrame;
      }
      }

      ns.onMetaData = function(info) {
      ns.duration = info.duration;
      }

      //-------ATTACHING NETSTREAM--------------
      video.attachVideo(ns);

      //-------PLAYING EXTERNAL FLV--------------
      ns.play("curse.flv");

      //-------REWIND BUTTON--------------
      rewind.onRelease = function() {
      ns.seek(0);
      }

      //-------PLAY PAUSE TOGGLE--------------
      playPause.onRollOver = function() {
      if(this._currentframe == 1) {
      this.gotoAndStop("pauseOver");
      }
      else {
      this.gotoAndStop("playOver");
      }
      }

      playPause.onRollOut = function() {
      if(this._currentframe == 10) {
      this.gotoAndStop("pause");
      }
      else {
      this.gotoAndStop("play");
      }
      }

      playPause.onRelease = function() {
      if(this._currentframe == 10) {
      this.gotoAndStop("playOver");
      ns.pause(true);
      }
      else {
      this.gotoAndStop("pauseOver");
      ns.pause(false);
      }
      }

      //-------LOADBAR--------------
      loadbar.onEnterFrame = function() {
      this._xscale = (ns.bytesLoaded/ns.bytesTotal)*100;
      if(this._xscale == 100) {
      delete this.onEnterFrame;
      }
      }

      //-------VIDEO UPDATE--------------
      function videoUpdate() {
      progressBar._xscale = (ns.time/ns.duration)*100;
      }

      //-------VIDEO SCRUBBER--------------
      loadbar.onPress = function() {
      progressBar.onEnterFrame = videoScrub;
      }

      loadbar.onRelease = loadbar.onReleaseOutside = function() {
      progressBar.onEnterFrame = videoUpdate;
      }

      function videoScrub() {
      var dist:Number = (_root._xmouse-loadbar._x)/loadbar._width;
      ns.seek(Math.floor(ns.duration*dist));
      progressBar._xscale = (ns.time/ns.duration)*100;
      }