0 Replies Latest reply on Sep 26, 2011 2:16 AM by ClintGossettSF

    Saving FLA Downloaded With URLLoader

    ClintGossettSF

      I'm downloading a FLV file using the URLLoader, then trying to save the file to my file system.  I keep getting an error that says the contents of my "URLLoader().data" variable cannot be converted to a ByteArray.    I do set myUrlLoader.dataFormat = URLLoaderDataFormat.BINARY before loading.     

       

       private function loaderCompleteHandler(event:Event):void
      {
                var loader:URLLoader               = event.currentTarget;
      
      
                // Creating file to write to :  Seems to work fine
      
               var tempFile:File                       =    File.desktopDirectory.resolvePath( "newFile.flv" ); 
               File.createTempFile().moveTo( tempFile, true );
      
                var fileStream:FileStream          = new FileStream();
                fileStream.open( tempFile ,FileMode.WRITE );
      
                // This line produces the error;
               fileStream.writeBytes( loader.data, 0, loader.bytesTotal );
      
      
                fileStream.close();
      }
      

       

      What am I doing wrong here?