0 Replies Latest reply: Jul 9, 2014 4:51 PM by crankydragon RSS

    Adobe Media Server - ByteArray

    crankydragon

      How are you supposed to access the data in a ByteArray? ByteArray.readBytes reads into another byte array which perpetuates the problem. I want to return the data so that I can manipulate it. What am I missing?

       

       

          var data  = new ByteArray();
          var file  = new File(path);
          var pos   = 0;
          var bytes = 500 * 1024; // bytes
      
          if( !file.exists ) {
              trace(path + ' does not exist');
              return;
          }
         /*
          | Opens an FLV file in binary mode
          */
          if( !file.open('binary', 'read') ) {
               trace('Cannot open file');
               return;
          }
      
          if( file.length < bytes ) {
              bytes = file.length;
          }
           
          /*
          | Neither valueOf or toString provide the data I want.
          | Both return "FLV" as a value not the data.
          */
          file.readBytes(data, pos, bytes);
          trace(data.valueOf());  // DOES NOT WORK
          trace(data.toString()); // DOES NOT WORK