title: How Can I save a MovieClip (Bitmap and Audio) to FLV?
body: <p>This is my first question here :D, first sorry about my english.</p>
  
  <p>My question is basically how can i save a flash Movie Clip to FLV.</p>
  
  <p>The Movie Clip is generated by users and it has various sounds and animations and i need to save an FLV to send it to Youtbue.</p>
  
  <p>What have I tried:
  I found some question here about using an Alchemy Lib that I am using to grab the Movie Clip frame to frame and save it to Bitmap.</p>
  
  <p>The Alchemy Lib converts those frames to FLV like a charm and supports saving chunks of sound using ByteArray. </p>
  
  <p>In this situation my Problem is, how can i grab the sound of Movie Clip to send it to Alchemy Lib?
  I´ve tried using:</p>
  
  <pre><code>SoundMixer.computeSpectrum(sndData, false, 2);
  </code></pre>
  
  <p>Witch returns me a byteArray in sndData variable but is useless since it´s used for render Audio Wave forms on screen. </p>
  
  <p>Thougth aboud using </p>
  
  <pre><code>Sound.extract();
  </code></pre>
  
  <p>but i believe the sound class is used only for one MP3 sound and I need to grab the mixed sounds generated by Movie Clip.</p>
  
  <p>Is there another way to generate the FLV from a MovieClip?</p>
  
  <p>Below some of my code:</p>
  
  <p>I based my code under the tutorial that I found in this link: <a href="http://www.zeropointnine.com/blog/updated-flv-encoder-alchem/" rel="nofollow">http://www.zeropointnine.com/blog/updated-flv-encoder-alchem/</a></p>
  
  <pre><code>private const OUTPUT_WIDTH:Number = 550;
  private const OUTPUT_HEIGHT:Number = 400;
  private const FLV_FRAMERATE:int = 24;
  private var _baFlvEncoder:ByteArrayFlvEncoder;      
  public var anime:MovieClip;
  
  
  //Starts recording
  public function startRecording()
  {
      this.addEventListener(Event.ENTER_FRAME, enterFrame);
  
      //Initialize the Alchemy Lib
      _baFlvEncoder = new ByteArrayFlvEncoder(stage.frameRate);
      _baFlvEncoder.setVideoProperties(OUTPUT_WIDTH, OUTPUT_HEIGHT);
      _baFlvEncoder.setAudioProperties(FlvEncoder.SAMPLERATE_22KHZ);
      _baFlvEncoder.start();      
  
  }
  //Stops recording
  public function stopRecording()
  {
      this.removeEventListener(Event.ENTER_FRAME, enterFrame);
      _baFlvEncoder.updateDurationMetadata();
  
      // Save FLV file via FileReference
      var fileRef:FileReference = new FileReference();
      fileRef.save(_baFlvEncoder.byteArray, "test.flv");          
  
      _baFlvEncoder.kill();
  
  }
  
  //The Main Loop  activated by StartRecording
  public function enterFrame(evt:Event)
  {
      var bmpData:BitmapData = new  BitmapData(OUTPUT_WIDTH, OUTPUT_HEIGHT, false, 0xFFFFFFFF);
      bmpData.draw(anime);
  
      var sndData:ByteArray = new ByteArray();
      SoundMixer.computeSpectrum(sndData, false, 2);
  
      _baFlvEncoder.addFrame(bmpData, sndData);
      bmpData.dispose();
  
  
  }
  </code></pre>