0 Replies Latest reply on May 8, 2006 3:40 AM by MatMaar

    NaN with loading external flv

    MatMaar
      Hi all

      I'm having some strange diffulties which I can't solve.

      I'm starting off with a website.swf which loads different external swf's depending on the button that has been pressed.
      One of those swf's is a file with different buttons to load different external flv's.
      While loading a flv a progressbar shows the percentage of the loaded part of the flv

      Now: If I play the first video file everything works fine
      While switching to another button to load another flv during the loading of the first flv, My percentage says NaN. and stops loading.

      On each button I say:

      on (press) {
      stream_ns.close();
      connection_nc.close();
      _parent.videoloader_mc.unloadMovie();
      }
      on (release) {
      _parent.videoloader_mc.loadMovie("movies/binnenkomers01.swf");
      }



      This is the part I use for loading a flv in f.ex binnenkomers01.swf.
      stop();
      delete _global.loaded_interval;
      delete _global.connection_nc;
      delete _global.stream_ns;
      delete _global.pctLoaded;


      // video URL
      video1_url = "movies/binnenkomer06_Floriane.flv";



      _global.connection_nc = new NetConnection();
      connection_nc.connect(null);
      _global.stream_ns = new NetStream(connection_nc);
      videoholder_mc.video.attachVideo(stream_ns);
      stream_ns.play(video1_url);
      stream_ns.seek(0);
      // Zet de video op stop om te wachten tot hij volledig is ingeladen
      stream_ns.pause();
      _global.playstatus = "pauze";
      play_pauze_mc.gotoAndStop("pauze_lb");


      this.createEmptyMovieClip("progressBar_mc", this.getNextHighestDepth());
      progressBar_mc.createEmptyMovieClip("bar_mc", progressBar_mc.getNextHighestDepth());
      with (progressBar_mc.bar_mc) {
      beginFill(0xCCE6FF);
      moveTo(0, 0);
      lineTo(300, 0);
      lineTo(300, 23);
      lineTo(0, 23);
      lineTo(0, 0);
      endFill();
      _xscale = 0;
      }

      progressBar_mc.createEmptyMovieClip("stroke_mc", progressBar_mc.getNextHighestDepth());
      with (progressBar_mc.stroke_mc) {
      lineStyle(0, 0xCCE6FF);
      moveTo(0, 0);
      lineTo(300, 0);
      lineTo(300, 23);
      lineTo(0, 23);
      lineTo(0, 0);
      }
      progressBar_mc._x = 640;
      progressBar_mc._y = 400;

      this.createTextField("loaded_txt", this.getNextHighestDepth(), 0, 0, 200, 22);
      loaded_txt._x = 645;
      loaded_txt._y = 405;

      var my_fmt:TextFormat = new TextFormat();
      my_fmt.color = 0x333333;
      my_fmt.font = "Verdana";
      my_fmt.size = 9;
      my_fmt.align = "left";


      _global.loaded_interval = setInterval(checkBytesLoaded, 500, stream_ns);



      function checkBytesLoaded(stream_ns) {
      trace("my_ns.bytesLoaded: "+stream_ns.bytesLoaded);
      trace("my_ns.bytesTotal: "+stream_ns.bytesTotal);
      _global.pctLoaded = Math.round(stream_ns.bytesLoaded/stream_ns.bytesTotal*100);
      trace("_global.pctLoaded: "+_global.pctLoaded);
      loaded_txt.text = "loading... "+pctLoaded+"%";
      loaded_txt.setTextFormat(my_fmt);
      progressBar_mc.bar_mc._xscale = pctLoaded;

      if (isNaN(pctLoaded)) {
      clearInterval(loaded_interval);
      } else {
      trace("OK");
      }
      if (pctLoaded>=100) {
      clearInterval(loaded_interval);
      }
      }



      Hope you guys can help me....