Schemaphic Systems Blog

Sharing experiences in Flash, Flex and AIR

Screen capture with ActionScript

with 63 comments

While working over numerous projects I often had requirements for doing screen capture in AS3.0. Unfortunately I found none in google search, but got some resources which helped me to develop a component for screen capture.

With a hope that this will someone out there, I have posted it here:

Below is the Main mxml page developed using Adobe Flash Builder, SDK 4.1, Flash Player version 10.1.0. In this example I am doing a screen capture of the stage.
I have added a video and placed 3 buttons, Record, Stop and Play.
On clicking on the Record button, the recording of the page starts. Once you click on stop, it stops recording.
Then click on Play button to see the recorded version. You may have other things/animations on stage for recording too, I have just tried with an flv.
The recording play is basically bytesArray of an FLV created on run-time. You can save it to your server by passing this binary data to any back-end technology – ASP.Net or PHP, etc.
//Main.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="955" height="600"
addedToStage="onInit();"
frameRate="24" >

     <fx:Script>
<![CDATA[
             import com.dd.screencapture.ScreenCapture;
             import com.dd.screencapture.SimpleFlvWriter;

             private var screenCapture:ScreenCapture;

             private function onInit():void
             {
                  screenCapture = ScreenCapture.getInstance();
                  screenCapture.source = stage;
                  screenCapture.fps = 12;
                  screenCapture.size( 400, 300 );
                  screenCapture.x = 400;
                  screenCapture.y = 250;
                  stage.addChild( screenCapture );
             }

             private function startRecord( event:MouseEvent ):void
             {
                   screenCapture.record();
             }

             private function stopRecord( event:MouseEvent ):void
             {
                  screenCapture.stop();
             }

             private function playVideo( event:MouseEvent ):void
             {
                  screenCapture.play();
             }
      ]]>
   </fx:Script>
   <s:VideoDisplay width="400" height="300" source="assets/myVideo.flv" />

   <mx:HBox >
       <s:Button label="Record" click="startRecord( event );" />
       <s:Button label="Stop" click="stopRecord( event );" />
       <s:Button label="Play" click="playVideo( event );" />
   </mx:HBox>
</s:Application>

Place this swc in library of the flex project. You may also use this for ActionScript 3.0 projects as well.

Kindly note that this requires Flash Player 10.1 to run properly. No audio capabilities here.

Interestingly, you can save the screen capture as FLV format by using this piece of code below:

var saveFile:FileReference = new FileReference();
saveFile.save( screenCapture.data, "video.flv" );//screenCapture is the ScreenCapture instance created in the above code block.

Resources used: http://www.zeropointnine.com/blog/simpleflvwriteras-as3-class-to-create-flvs/
The links shows how to save BitmapData to an FLV in binary format and then save to dish using Adobe AIR, using FileStream. I have taken the part of writing the binary data for FLV and playing that FLV as stream on run-time.

Do leave me a note if this helps you.
Cheers 🙂

Advertisements

Written by Deepanjan Das

February 5, 2011 at 1:31 PM

63 Responses

Subscribe to comments with RSS.

  1. Hi,

    Interesting screen capture app.
    I’m having trouble with it, hope someone can help.

    So I’ve got the main.mxml and screenCapture.swc on flex, and then i’ve made a simpleFlvWriter.as from the link above and then put it on the lib folder?

    Am I doing something wrong?

    flashysite

    February 10, 2011 at 11:14 PM

    • The ScreenCapture already has the SimpleFLVWriter.as as class in it but a modified version.
      So that might have caused the problem.
      Anyways, if you just do the following, it should work:
      1. copy paste the code above in a MXML project (I used Adobe Flash Builder 4)
      2. place the ScreenCapture.swc in lib folder
      3. Check that the Flex Compiler uses SDK 4.1
      4. The target flash player should be 10.1.0 or above.

      Thats all! Let me know if you still have a problem 🙂

      Best
      DD

      Deepanjan Das

      February 11, 2011 at 8:02 AM

  2. How can we implement the sound to a screen capture to FLV

    And if it run in the web page and save th FLV to the server ?

    THANK U VERY MUTCH FOR YOUR JOB

    COCA1

    March 4, 2011 at 9:53 PM

    • Hi Coca1,
      Thanks for visiting my blog.

      The audio has not been implemented here. While recording, it may not be wise to record the audio as well.
      This is because, if the process somewhere becomes slower for large recording length, then the audio might get disrupted due to frame skipping.
      Hence it will be advisable to integrate audio with the flv. I am trying to do that in as separate application but no news to cheer up on this at this moment.

      Regarding saving to server, yes it can be done using any back-end programme like PHP, ASP.NET. The flash application will send bytesArray to the programme to save it in the server.

      Deepanjan Das

      March 5, 2011 at 2:37 PM

  3. great job… this is very useful, is there any chance you post the .as files of ScreenCapture; SimpleFlvWriter;

    Seemo

    March 10, 2011 at 8:31 AM

  4. if there isn’t 😦
    can we modify the flv video quality so we reduce the file size?

    thanks in advance 🙂

    Seemo

    March 10, 2011 at 8:47 AM

    • I do have the files but not at this point, may be will send you in the next couple of hours when I get back.

      Yes you can change the video quality of the output. For that you will need to edit the FLVFileWriter.as
      for I have not created a public API for that. Any way once I provide you the source, you will be able to edit that yourself, In case you are still stuck, let me know.

      Cheers
      DD

      Deepanjan Das

      March 10, 2011 at 8:55 AM

      • I don’t know how to thank you, I’m out of words…
        looking forward for your email,

        Tons of thanks Deepanjan Das 🙂

        Seemo

        March 10, 2011 at 9:03 AM

        • ScreenCapture.as
          /*
          EXAMPLE USAGE:

          var screenCapture:ScreenCapture = ScreenCapture.getInstance();
          screenCapture.source = stage;
          screenCapture.fps = 30;
          screenCapture.size( 400, 300 );
          screenCapture.record();
          screenCapture.stop();
          //
          addChild( screenCapture );
          screenCapture.play();
          screenCapture.pause();
          screenCapture.data;
          screenCapture.isRecording;
          screenCapture.clear();
          */

          package com.dd.screencapture
          {
          import flash.display.BitmapData;
          import flash.display.Sprite;
          import flash.media.Video;
          import flash.net.NetConnection;
          import flash.net.NetStream;
          import flash.utils.ByteArray;
          import flash.utils.clearInterval;
          import flash.utils.setInterval;

          public class ScreenCapture extends Sprite
          {
          private static var instance:ScreenCapture;
          private var _source:*;
          private var _fps:int;
          private var _isRecording:Boolean = false;

          private var recordingInterval:uint;
          private var displayWidth:Number;
          private var displayHeight:Number;
          private var myWriter:SimpleFlvWriter;
          private var video:Video;
          private var ns:NetStream;

          public function ScreenCapture( enf:SingletonEnforcer )
          {
          super();

          myWriter = SimpleFlvWriter.getInstance();
          myWriter.create();
          }

          public static function getInstance():ScreenCapture
          {
          if( ScreenCapture.instance == null )
          ScreenCapture.instance = new ScreenCapture(new SingletonEnforcer());
          return ScreenCapture.instance;
          }

          public function set source( value:* ):void
          {
          _source = value;
          }

          public function set fps( value:int ):void
          {
          _fps = value;
          myWriter.fps = _fps;
          }

          public function get data():ByteArray
          {
          return myWriter.bytes;
          }

          public function get isRecording():Boolean
          {
          return _isRecording
          }

          public function size( w:Number, h:Number ):void
          {
          displayWidth = w;
          displayHeight = h;

          myWriter.frameWidth = displayWidth;
          myWriter.frameHeight = displayHeight;
          }

          public function record():void
          {
          if( _isRecording )
          return;

          _isRecording = true;
          recordingInterval = setInterval( getBitmapData, ( 1000 / _fps ) );
          }

          public function stop():void
          {
          if( !_isRecording )
          return;

          clearInterval( recordingInterval );
          myWriter.close();
          }

          public function play():void
          {
          if( video ){
          ns.play( null );
          //ns.appendBytes( myWriter.bytes );
          }else{
          createVideo();
          }
          }

          public function pause():void
          {
          if( video ){
          ns.pause();
          }
          }

          public function clear():void
          {
          if( video ){
          ns.close();
          ns = null;

          removeChild( video );
          video = null;
          }

          if( recordingInterval){
          clearInterval( recordingInterval );
          }

          _source = null;
          _fps = 0;
          _isRecording = false;
          }

          private function getBitmapData():void
          {
          try{
          var bmd:BitmapData = new BitmapData( _source.width, _source.height, true, 0x000000 );
          bmd.draw( _source, null, null, null, null, true );
          myWriter.saveFrame( bmd );
          } catch ( error:Error ){
          trace( error );
          }
          }

          private function createVideo():void
          {
          // create video
          video = new Video( displayWidth, displayHeight );
          video.name = “Video”;
          var nc:NetConnection = new NetConnection();
          nc.connect( null );

          ns = new NetStream( nc );
          ns.client = {};
          video.attachNetStream( ns );

          // important: play(null), otherwise exception
          ns.play( null );

          // play byte array
          ns.appendBytes( myWriter.bytes );

          //addChild for display
          addChild( video );
          }
          }
          }

          class SingletonEnforcer {}

          Deepanjan Das

          March 10, 2011 at 9:05 PM

          • Thank you so much my friend, I’m really grateful 🙂

            Seemo

            March 10, 2011 at 9:29 PM

            • This is awesome Deepanjan, I’ve just modified the SimpleFlvWriter.as just to replace the File type with the ByteArray, and this goes fine… 🙂
              Now I’ll try to reduce the Flv Quality.

              Thank you man you’re an AS3 angel 🙂

              Seemo

              March 10, 2011 at 11:48 PM

      • Deepanjan, I also need FLVFileWriter class can you mail me, i will be greatful to you

        Lokesh gahlot

        May 24, 2011 at 9:21 PM

        • I am sorry i didn’t read your request before, but sure i’ll send to you as soon as i get access to my computer at work, sorry again…. 😉

          seemo

          December 17, 2011 at 3:10 PM

  5. thank you so much for your quick response

    Seemo

    March 10, 2011 at 8:49 AM

  6. This is awesome , But i want to know when i record 25 sec. with 12 fps, created video length only approx 8-10 sec. actually video is compressing. can we solve this please suggest.

    Lokesh gahlot

    May 24, 2011 at 9:11 PM

    • Hi Lokesh,
      Sorry for the late reply, I was on holidays out of town.

      I have seen the issue you have pointed. Thanks dude for making me mad at it. I will try to fix that shortly, I will ping you on complete.

      Deepanjan Das

      June 5, 2011 at 2:13 PM

  7. hi do u think you can include audio as well? may be this can help

    http://code.google.com/p/e4xu/source/browse/trunk/src/org/wvxvws/encoding/FLVTranscoder.as

    shammi

    June 1, 2011 at 8:34 PM

  8. Hi! Sorry, but i can’t to run ScreenCapture application. I have a latest version of SDK…I created new desktop Air project and moved files ScreenCapture.as and SimpleFLVWriter.as at /src directory. and copyed ScreenCapture.swc at C:\Program Files\Adobe\Adobe Flash Builder 4.5\sdks\4.5.1\frameworks\libs\air\ …..I’ve got an error:

    initial content no found

    Please help me.

    Thanks in advance

    linnard

    June 25, 2011 at 7:35 PM

    • Just use the swc and the code I gave, no need to use the class files individually.

      Also add the swc like you add other swcs in project from the properties panel.

      Best
      Deepanjan

      Deepanjan Das

      June 25, 2011 at 9:54 PM

      • Ok. i did it, but error still exists (initial content no found). Can you send me finished project on my e-mail, please (linnard123@gmail.com) or upload project to a convenient for you sharing?

        linnard

        June 27, 2011 at 5:41 PM

      • Ok, so far as I’ve read, Deepanjan is the Man… While using the SWC, the thing works as expectyed, but trying to change the source to capture other DisplayObject than the stage, can’t get it to work. Deepanjan, you told the ScrreenCapture Class already had you extended version of the SimpleFlvWriter, but the one above doesn’t seem to have it.
        Any chance of a zip project with ScreenCapture and your extended version of the FLVWriter with FileReference for web deployment?! I guess if you place it here, it’ll be dnloaded ad aeternum… I’ll be among the starters.. Keep up the good work!

        liopalma

        July 18, 2011 at 9:31 PM

  9. Ya very good article. You have given a solutions for my long time problems. thanks a lot

    Bala

    July 15, 2011 at 12:57 PM

  10. ciao, scusa per il mio inglese.
    Ho provato ad utilizzare ScreenCapture.swc. io sto usando flash cs5.

    il mio flv risulta una schermata nera, quale può essere il problema?

    grazie

    Riccardo

    //—————————————–

    package {

    import flash.display.MovieClip;
    import flash.events.*;
    import flash.ui.*;
    import flash.net.FileReference;
    import com.dd.screencapture.ScreenCapture;
    import com.dd.screencapture.SimpleFlvWriter;

    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.utils.ByteArray;
    import flash.utils.clearInterval;
    import flash.utils.setInterval;

    public class provaVideo extends MovieClip {

    private var screenCapture:ScreenCapture;

    public function provaVideo() {

    onInit();

    }

    private function onInit():void

    {
    screenCapture = ScreenCapture.getInstance();
    screenCapture.source = stage;
    screenCapture.fps = 30;
    screenCapture.size( 400, 300 );
    screenCapture.x = 400;
    screenCapture.y = 0;
    stage.addChild( screenCapture );
    screenCapture.data;
    screenCapture.isRecording;
    //rec
    rec_pb.addEventListener(MouseEvent.CLICK,startRecord);
    rec_pb.buttonMode = true;
    //stop
    stop_pb.addEventListener(MouseEvent.CLICK,stopRecord);
    stop_pb.buttonMode = true;

    }

    private function startRecord( event:MouseEvent ):void
    {
    rec_pb.buttonMode = false;
    rec_pb.removeEventListener(MouseEvent.CLICK,startRecord);
    screenCapture.record();
    }

    private function stopRecord( event:MouseEvent ):void
    {
    rec_pb.addEventListener(MouseEvent.CLICK,startRecord);
    screenCapture.stop();
    var saveFile:FileReference = new FileReference();
    saveFile.save( screenCapture.data, “video.flv” );//screenCapture is the ScreenCapture instance created in the above code block.

    }

    private function playVideo( event:MouseEvent ):void

    {
    screenCapture.play();
    }

    }

    }

    Riccardo

    August 9, 2011 at 5:51 PM

  11. Hello, sorry for my English.
    I tried using ScreenCapture.swc. I am using Flash CS5.

    My flv is a black screen, which can be the problem?

    thanks

    Richard

    //—————————————–

    package {

    import flash.display.MovieClip;
    import flash.events.*;
    import flash.ui.*;
    import flash.net.FileReference;
    import com.dd.screencapture.ScreenCapture;
    import com.dd.screencapture.SimpleFlvWriter;

    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.utils.ByteArray;
    import flash.utils.clearInterval;
    import flash.utils.setInterval;

    public class provaVideo extends MovieClip {

    private var screenCapture:ScreenCapture;

    public function provaVideo() {

    onInit();

    }

    private function onInit():void

    {
    screenCapture = ScreenCapture.getInstance();
    screenCapture.source = stage;
    screenCapture.fps = 30;
    screenCapture.size( 400, 300 );
    screenCapture.x = 400;
    screenCapture.y = 0;
    stage.addChild( screenCapture );
    screenCapture.data;
    screenCapture.isRecording;
    //rec
    rec_pb.addEventListener(MouseEvent.CLICK,startRecord);
    rec_pb.buttonMode = true;
    //stop
    stop_pb.addEventListener(MouseEvent.CLICK,stopRecord);
    stop_pb.buttonMode = true;

    }

    private function startRecord( event:MouseEvent ):void
    {
    rec_pb.buttonMode = false;
    rec_pb.removeEventListener(MouseEvent.CLICK,startRecord);
    screenCapture.record();
    }

    private function stopRecord( event:MouseEvent ):void
    {
    rec_pb.addEventListener(MouseEvent.CLICK,startRecord);
    screenCapture.stop();
    var saveFile:FileReference = new FileReference();
    saveFile.save( screenCapture.data, “video.flv” );//screenCapture is the ScreenCapture instance created in the above code block.

    }

    private function playVideo( event:MouseEvent ):void

    {
    screenCapture.play();
    }

    }

    }

    Riccardo

    August 9, 2011 at 7:14 PM

  12. It possibly use capture stream to FMS , fornext stream record on server side ?

    andrey

    August 22, 2011 at 1:36 AM

  13. Hey friend I did exactly as u said but still getting an error
    can u please send me u’r project at this email id sunnythangaraj@aol.com

    I really want your help
    please help me out
    please

    Sunny

    October 13, 2011 at 1:04 PM

  14. Thanks for developing excellent code.

    I have integrated this code in flash and worked excellent.

    Now, when I play video,at the end instance of screenCapture class remain on stage stage,i wana remove the instance of screenCapture calss how will i do…?

    Patrick

    November 19, 2011 at 1:16 PM

    • how do you get this to work by using just flash CS5 AND Actionscript 3
      Please help… Really stuck

      Thanks

      john doo

      January 16, 2012 at 1:42 AM

      • Hi,
        I am sorry for being so late.
        Do you still need this?

        Deepanjan Das

        Deepanjan Das

        February 8, 2012 at 7:10 PM

        • hi Deepanjan Das

          I love to see this done in Flash cs5 (actionscript 3) want to use it for a college project and have tried every thing.

          How can i get code????

          Thanks

          my email is dugganroy@gmail.com

          roy

          February 23, 2012 at 4:47 AM

          • Hi,
            Use the swc and add it to your project, then just use the code as per documentation and you should be there. In case you still face the problem, send me the zip of the short demo you are trying to do, I would try to take out some time to look into the same.

            Deepanjan Das

            Deepanjan Das

            February 23, 2012 at 6:31 AM

            • hi,

              Thanks for the quick reply really appreciate it

              Not good at this 😦

              Sorry But still stuck

              This is what i did:

              1. I created flash flie (test.fla) and placed it in folder

              2. created folder within root folder and put SWC file into it

              3. in test.fla went to—- publish settings—–flash tab—–settings —–library path—–browse to path icon and added swc file.

              4. scopied folder ( com.dd.screencapture ) into root folder for the ScreenCapture and SimpleFlvWriter files

              5. set up buttons with event listeners for play pause and stop actions

              So question…… when you say then just use the code as per documentation

              what code goes into actions panel in flash cs 5????????

              is it the code below and how do i get video display in as3 like

              ??????

              roy

              February 24, 2012 at 12:45 AM

  15. Many thanks
    I’d never reach this result without your help
    Powerfull & very easy to use

    MBall

    November 22, 2011 at 5:37 AM

  16. That’s amazing! Can this be done using AS2?

    Davis

    December 13, 2011 at 7:19 AM

  17. HELLO,
    can we record audio using this API ??
    if not so Please suggest me any other way to record system sound …..!!!

    Jigar Patel

    December 15, 2011 at 9:57 AM

  18. Hai.. thanks for your code.From your code i successfully done video Capture.But problem is audio with video,then I try these link http://www.zeropointnine.com/blog/updated-flv-encoder-alchem/ and solve screenrecorder in air application.But i try to web application issues are blocked.so please suggestion screen recorder in web application.I am waiting for your reply

    murugan

    February 7, 2012 at 7:18 PM

    • Hi Siva, So what issue are you facing?
      Please let me know. Also the swc I shared does not yet have the audio recording part. So it has to be done using the link you have already mentioned.

      Deepanjan

      Deepanjan Das

      February 8, 2012 at 7:10 PM

  19. Hi Deepanjan Friends Iam here To know The Video capturing of My computer screen i have play pause start buttons when i press start it start the record of screen.When i press stop stop the recording.When i press Play button it plays the recorded video of my screen and also i stored to sqlserver please help me iam waiting for rply.If possible provide source code to me..

    nagendrareddy

    May 1, 2012 at 12:10 PM

    • You need to use the swc which will do the recording of the flash area, not of the desktop.

      DDhttps://deepanjandas.wordpress.com/wp-admin/edit-comments.php?comment_status=moderated#comments-form

      Deepanjan Das

      January 11, 2013 at 4:42 PM

  20. Hello,

    Would it be possible to post a simple, step-by-step guide to implementing this code into a Flash CS5 project (for an ignorant beginner)? Would be greatly appreciate — thanks very much for your help.

    James

    May 17, 2012 at 12:47 PM

  21. Is this swc relevant for Mobile apps also. I tried doing it but it gives me an error: Error #1009: Cannot access a property or method of a null object reference

    Pooja Gupta (@Pooja_Gupta)

    September 3, 2012 at 3:48 PM

    • I developed it to be used for web applications using AS3.0. Theoretically it should have worked, but need to check for the error. The error that you have posted is generic, if you can provide some more info, it would be great.

      Deepanjan Das

      September 3, 2012 at 3:53 PM

      • Thanks for the reply Deepanjan. Here is what I did:

        1. Made a new Flex Mobile Project in Flash Builder 4.6
        2. Copied the above code in it.
        3. The code works, if I make a web browser app. But gives me the above error in mobile app.
        4. On debugging I found that ‘screenCapture’ object’s value is null.

        Looking forward to your response.

        Pooja Gupta (@Pooja_Gupta)

        September 4, 2012 at 11:04 AM

  22. Hi! thanks for the great example of videocapturing. i was able to run it locally and it works just fine. However, once I uploaded the bin folder to the webserver and tried to use it – I gor error #2032. Can you suggest something? Thank you,
    Alexander

    Alexander

    October 3, 2012 at 4:30 PM

    • #2032 error denotes stream error, please check any associated paths that you might be using.

      Deepanjan Das

      October 3, 2012 at 4:44 PM

  23. Thank you very much for your awesome ScreenCapture Class.

    I have some question about clearing data. For example, I take a screen capture video and save it to app:/myScreen.flv, How to record and save it again without concat from the old bytes?

    PS. I have already called clear(), but the old data still exist in the bytes.

    Nim

    November 28, 2012 at 4:24 PM

  24. hi~ i use the code to record my screen to flv, I record many times, but it’s all the same screen files, same with first time screen. it’s my code”

    import com.dd.screencapture.ScreenCapture;
    import com.dd.screencapture.SimpleFlvWriter;

    var screenCapture:ScreenCapture;
    var tft:File;//temp file

    // webcam capture

    import flash.media.Camera;
    import flash.media.Video;
    import com.adobe.images.JPGEncoder;
    import flash.net.FileReference;

    camera.buttonMode = true;
    camera.addEventListener(MouseEvent.CLICK,webcam);

    function webcam(event:Event):void
    {
    if (video.visible == true){
    video.visible = false ; webcam_title.visible = false; } else { video.visible = true; webcam_title.visible = true;}

    }

    // Web_cam import
    var cam:Camera = Camera.getCamera();
    var video:Video = new Video(320,240);
    video.attachCamera(cam);
    video.x = 30;
    video.y = 160;
    addChild(video);

    //web cam_record

    stop_bt.visible = false ;
    stop_bt.buttonMode = true;
    rec_view.visible = false;
    rec_bt.buttonMode = true;

    rec_bt.addEventListener(MouseEvent.CLICK,startRecord);
    stop_bt.addEventListener(MouseEvent.CLICK,stopRecord);
    play_bt.addEventListener(MouseEvent.CLICK,playVideo);
    //play_bt.addEventListener(MouseEvent.CLICK,playVideo);

    screenCapture = ScreenCapture.getInstance();
    screenCapture.source = video;
    //screenCapture.source = stage ;
    screenCapture.fps = 12;
    screenCapture.size( 320, 240);
    // screenCapture . x= 30;
    //screenCapture . y = 160;
    addChild( screenCapture );

    // if (rec_bt.visible == true ) rec_view.visible = false;
    // if (stop_bt.visible == true) rec_view.visible =true;

    function startRecord( event:MouseEvent ):void
    {

    screenCapture.record() ;
    rec_view.visible = true;
    rec_bt.visible = false;
    stop_bt.visible = true ;

    }

    var k:Number=1;

    function stopRecord( event:MouseEvent ):void
    {
    screenCapture.stop();
    rec_bt.visible = true ;
    stop_bt.visible = false;
    rec_view.visible = false;
    var saveFile:FileReference = new FileReference();
    saveFile.save( screenCapture.data, “video”+k+”.flv” );
    k++;//screenCapture is the ScreenCapture instance created in the above code block.
    }

    function playVideo( event:MouseEvent ):void
    {
    screenCapture.play();
    }

    fightclubtw

    December 12, 2012 at 11:47 AM

  25. Hey DD,
    While using your lib I got 2 problems:
    first, I got some performance issue as am capturing some animations.
    second, when I save to flv using the couple of lines u provided, it give me a corrupted flv file .. here is my code:

    <![CDATA[

    import mx.collections.ArrayCollection;
    import mx.containers.Canvas;
    import mx.controls.Button;
    import mx.controls.Image;
    import com.dd.screencapture.ScreenCapture;
    import com.dd.screencapture.SimpleFlvWriter;

    private var screenCapture:ScreenCapture;

    var movIdx:Number = 0;
    var onMov:Boolean = false;
    private var _points:Array = new Array();

    public function getArrOfPnts():Array {
    var pnts:Array = [
    {x: animObj.x,y: animObj.y},
    {x:180, y:20},
    {x:200 ,y:100 },
    {x: 150,y: 150},
    {x: 150,y: 250},
    {x:400, y:250},
    {x:450, y:200},
    {x:500, y:200},
    {x:600, y:20} ]; //array of points
    return pnts;

    }

    protected function onMoveClick(event:MouseEvent):void
    {
    movIdx = 0;
    _points = getArrOfPnts();
    animation.target = animObj;
    playBack();
    }

    protected function playBack():void {
    if(movIdx

    Ahmed Asfora

    January 29, 2013 at 7:14 PM

    • Hello Ahmed,
      I just created this swc while playing things out, not for direct production, so there may be performance hits. that is why i have also shared the source code for advance users who are allowed to change it 🙂

      Deepanjan Das

      Deepanjan Das

      March 22, 2013 at 9:53 AM

  26. I want to capture web page area…Using screen capture I am able to record…but only the flash stage area and not other things visible in the html webpage in which the .swf file is embedded…Plz help me..how can i record the visible portion of webpage also?

    cherry

    March 21, 2013 at 12:13 PM

    • Hello,
      This swc only supports screen capture of area within flash interface, not the whole of desktop. For that you need to java coding with flash like what adobe connect does. needs to install a client-plugin for the same.

      Deepanjan Das

      Deepanjan Das

      March 22, 2013 at 9:29 AM

  27. This looks perfect for what I need at the moment. Still I would like to build from source. Could you send me the two .as files by mail? asimov6(at)gmail.com. Would be much appreciated.
    thanks in advance.
    Asimov

    asimov

    June 23, 2013 at 3:55 AM

  28. Hi Deepanja, thanks a lot for this code! This link seems to be dead: http://www.zeropointnine.com/blog/simpleflvwriteras-as3-class-to-create-flvs/ Could you help me recover the file? Also i was wondering if you ever got round to adding sound to this capture system? Thank you so much a gain!!!

    leeborn

    December 3, 2013 at 3:05 PM

  29. Hi thanks for the great work this is exactly what I needed. However my app works in full screen mode which is 1280×1024 and when I record such a screen size the app becomes completly unusable. To slow. So I was hoping you could give me some advice as to how I can use ur screencapture with a screen size of 1280×1024. The quality does not need to be neither the fps I just need to see what the user is doing to help him. Thanks

    davsantos

    June 1, 2014 at 9:57 PM

  30. Hi I need to capture a screen size of 1280×1024. When I use ur screencapture with that screen size the application becomes to slow. Any idea how I could make it faster. The quality of the video is not important I just need to be able to see where the user clicked so I can help him.

    davsantos

    June 1, 2014 at 10:01 PM

    • Hi davsantos,
      First, let me thank you for using this code snippet.
      There is a common problem with flash player, that it cannot do multi-threading, also at the same time some goof PC configuration is required when a code is running continuously which performs some complex things. Here the code is reading the pixels and creating bitmapdata on every frame.

      Now in your case, the dimension is more, so a more area is covered for reading the screen. It will be difficult to save a screencast even for 20 secs play.
      Some code cleaning on the basis of performance for flash player may lead to some improvements but I am afraid it will not be something visually effective.

      Alternatively I can suggest you that even though you have a larger screen to display, just resize the bitmap while saving to a smaller dimension and that will give you a more leverage to performance. I guess you have access to the raw code as well.

      Have a great day!

      Deepanjan Das

      June 2, 2014 at 7:25 AM

  31. Hi,

    This is really useful class.
    I used your SWC , and created flv sucessfully , but it not opening in any of the players ( showing codec error) .

    anything I have missed ?

    Note: the output flv only opening inside flash ide , but nowhere its openening.

    Can u help me?

    Thanks in Advance,
    Rukmoni

    Rukmoni

    June 9, 2014 at 12:54 PM

  32. Hey DD
    am new to flex..and my assignment is screen sharing using red5 server.. can you help me plsss…
    can u please send me u’r project at this email id suganyathangavel92@gmail.com

    suganya

    August 5, 2014 at 3:15 PM

  33. Hello Deepanja, a million thanks for the classes that you wrote. I manage to implement it wright away! Extremely simple and comfortable to use!!! I did run to this frame rate problem though. When I record TweenLite animations its got cutted out in time. Although adjusting the frame rate and timing of the animations fixes that, but it is still different when I record from SWF or the same app when it is in EXE. Can you give me some more information about this issue?

    Thanks in advanced,
    Delyan.

    Delyan

    May 1, 2015 at 4:22 PM


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: