0 Replies Latest reply on Jun 22, 2010 9:56 AM by DSuess_33

    How can I append multiple parts to NetStream with appendBytes

    DSuess_33

      Hi,

       

      I hope  someone can help me.

       

      Problem:

       

      I load a flv file with the FileReference class. After that I append a part of the ByteArray to  the NetStream with appendBytes.

      Later I want a next part append to the NetStream. It doesn't work.
      Is that possible?

       

      Code:

       

                public function init():void
                  {

       

                      myFileRef = new FileReference();
                      myFileRef.addEventListener(Event.SELECT, selectFile);
                      myFileRef.addEventListener(Event.COMPLETE, playFile);
                      myOpenButton.addEventListener(MouseEvent.CLICK,browserForFile);                        
                  }

       

                  private function browserForFile(e:MouseEvent):void
                  {
                      myFileRef.browse([new FileFilter("Flash-Videos (*.flv)", "*.flv;")]);
                  }

       

                  private function selectFile(e:Event):void
                  {
                      myFileRef.load();
                  }
                 
                  private function playFile(e:Event):void
                  {
                      byteArr = myFileRef.data;
                     
                      var bytes:ByteArray = new ByteArray();
                      byteArr.readBytes(bytes, 0, 3031964);
                     
                      _netConnection = new NetConnection();
                      _netConnection.connect(null);            
                      ns = new NetStream(_netConnection);
                      ns.addEventListener(NetStatusEvent.NET_STATUS, netStreamStatusHandler);
                      ns.client = new Object();
                      display.attachNetStream(ns);
                      ns.play(null);
                      ns.appendBytes(bytes);
                      videoDisplay.addChild(display);
                  }
                 
                  private function loadNext():void
                  {
                      var bytes:ByteArray = new ByteArray();
                      byteArr.readBytes(bytes, 3031964, byteArr.bytesAvailable);
                     
                      ns.appendBytes(bytes);
                  }

       

      friendly

      Daniel