0 Replies Latest reply on Apr 21, 2007 4:26 PM by jawtab

    if FLV video (netStream) is loading but canceled bug

    jawtab
      this is a weird bug that has me stumped.
      I am loading the following movies into a placeholder MC on the timeline for 7 pages that have videos. all the netstream code is the same for each video that is loaded.

      everything works fine until I press my menu button to load a new page (SWF) with a new video before the current video is done loading. It causes the next video to no appear or auto play (ingnoring the pause toggle).

      Note this only also happens for my video FLV files are 1 megabyte in size. My other 100-450KB are fine if canceled early by a new page loading.

      Also not there is no problems if the videos are loaded to 100%.

      I thought the NAN value may have been a problem but I put a fix in there and didn't solve it.


      So here's the code. The same code is used in 6 files as containers to be loaded into the pages that have text and other content.

      They are called via the following on the main menu.
      stopAllSounds();
      _parent.clickMenuSound.start(0, 1);
      _root.gotoAndStop("blankpage");
      unloadMovie(_root.seanvideoPlaceholder_mc);
      unloadMovie(_root.content_mc);
      loadMovie("02 expeditions - page.swf", "_root.content_mc");

      so in my (ie.) 02 expeditions - page.swf, there is a callout on the timeline to load my (ie.) 02 expeditions - video.swf which would contain the following code, with a pause toggle to play then play when loaded to 80%.

      var connection_nc:NetConnection = new NetConnection();
      connection_nc.connect(null);
      var stream_ns:NetStream = new NetStream(connection_nc);
      my_video.attachVideo(stream_ns);
      stream_ns.play("sean talking videos/news.flv");
      stream_ns.pause();

      var loaded_interval:Number = setInterval(checkBytesLoaded, 5, stream_ns);
      function checkBytesLoaded(my_ns:NetStream) {

      var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
      loadPercent_mc.loaded_txt.text = Math.round(pctLoaded*1.25) + "%";
      progressBar_mc._yscale = pctLoaded*1.25 ;
      pctLoaded = (!isNaN(my_ns.bytesLoaded/my_ns.bytesTotal)) ? Math.ceil((my_ns.bytesLoaded * 100)/my_ns.bytesTotal) : 0 ;
      if (pctLoaded >= 80) {
      clearInterval(loaded_interval);
      loaded_txt.text._alpha = 0;
      progressBar_mc.bar_mc._alpha = 0;
      gotoAndStop("videoplay");
      stream_ns.pause();
      }
      }
      // Create function for NetStream object
      stream_ns.onStatus = function(infoObject:Object) {
      if (infoObject.code == "NetStream.Play.Stop") {
      trace("Video is stopped and done...");
      gotoAndPlay("videostopped");
      stream_ns.close();
      }
      }


      Is the netstream being reused globally and causing problems?

      I'm baffled. I have a beautiful preloader but got this project that must be done monday morning and going to have to resort to some ugly components.


      Thanks in advance.
      J