4 Replies Latest reply on Mar 2, 2011 7:19 AM by munkeymike

    Can I render a Flash frame as a bitmap and send it over TCP/IP?

    rpstrat

      I want to draw some combination of bitmaps, flash shapes, vectors, text etc and draw them programmatically into my movie using ActionScript, and then get every "rendered" pixel of my movie (at 100% view) into an array that I send to another program over TCP/IP. Can anyone help me here?

      The first part of the question is if its possible to render a frame that is a collection of Flash elements as a bitmap? I know that I can iterate through a bitmap and get every pixel using the getPixel method but I'm trying to access the final rendered frame displayed on my screen, including, as I said Flash shapes and text.

      The second question is what would be the best way to send this "video frame" over TCP/IP? Would I use an XML socket connection? That is the only way I know how to send data out of Flash over TCP/IP but I don't know if it is the only way - the help page says the data needs to be formatted as XML, which seems unwieldly for this application.

      I'm doing this now by using Max/MSP/Jitter to do a screen capture the size and location of my Flash movie and then send out the resulting matrix using a "jit.net.send" object (which lets you send frames of video over TCP/IP), but this is too clumsy for the installation I am building.

      Any help would be greatly appreciated!

      -bob

        • 1. Re: Can I render a Flash frame as a bitmap and send it over TCP/IP?
          munkeymike Level 2

          If what you want to display is a single clip, you could create a bitmapdata object then call the draw() method and pass the movieclip containing all your assets.

           

          As for the second part, I'm not so sure about that.

          • 2. Re: Can I render a Flash frame as a bitmap and send it over TCP/IP?
            Rothrock Level 5

            Not sure what you mean by access to your shapes and text. Some kind of representation of the screen that keeps all the separate parts separate and editable is going to be insanely complex, but a "screen shot" can be like munkeymike suggested using draw() method.

             

            Also if you are using AS3 you might want to look into using something like this:

             

            http://code.google.com/p/in-spirit/wiki/PNGEncoder

             

            Also I did a google search on sending a byteArray to a server and found the following that seem promising:

             

            http://www.zedia.net/2008/sending-bytearray-and-variables-to-server-side-script-at-the-sam e-time/

            http://www.quietless.com/kitchen/upload-bitmapdata-snapshot-to-server-in-as3/

             

            If you aren't using AS3, I think you are going to have some problems doing this.

            1 person found this helpful
            • 3. Re: Can I render a Flash frame as a bitmap and send it over TCP/IP?
              rpstrat Level 1

              Thanks! That was exactly what I was looking for in the first half of the question. And I guess the draw() method works in AS2 as well as AS3. I will test it but from what I understand, I can use a Bitmap as kind of my bottom-level container, then create (in ActionScript) a movie clip that can contain other movie clips or drawing API commands or whatever, animate these various elements then finally draw() them into the bitmap. I see that in AS3 I can even use getPixels or getVector to capture the full "video frame" in one line of code.

              Thanks rothrock, for the helpful links. My application is kind of unusual, in that I'm sending "video" data to a proprietary LED controller box for display on a low resolution LED display. I connect to the box over TCP/IP and send it "frames of video" 20 times a second. I got this to work with this other content and software (Max/MSP/Jitter) and I want to see how I could capture all the rendered pixel data in successive frames of Flash animation, format it properly, then send it over TCP/IP to this controller box. Don't really now enough about the various flavors of TCP/IP connections to figure out how to do this in Flash, and I know there are security limitations built in to Flash that have to be worked around. But my movies are small (say 96 pixels by 72 pixels) and I need to send uncompressed data directly to my controller box, so these interesting links showing how to use server-side scripts to create jpgs or pngs are probably not going to help me. I will hopefully find a higher-level programmer than myself to work this out, and I think some of the techniques here will hopefull prove to be helpful.

              Thanks again for your help!

              • 4. Re: Can I render a Flash frame as a bitmap and send it over TCP/IP?
                munkeymike Level 2

                I have some experience with Adobe Air and know for a fact that it can natively write out files to your local hard disk. Developing for Adobe Air is quite similar to developing for Flash.

                 

                I'm not sure if Air can connect directly to TCP/IP, but if you write out the files to your local disk then have a TCP/IP client that automatically syncs that folder with your controller box then that might work. I'm just throwing ideas out there.