A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: export as image using actionscript

Hybrid View

  1. #1
    Senior Member willi-jay's Avatar
    Join Date
    Sep 2000
    Posts
    116

    export as image using actionscript

    I've heard you can do this in version 8. I need to be able to export the flash stage as an image to be e-mailed to professors for an online course. Can someone lead me in the right direction?
    Willi-Jay
    ______________________________
    Creative Communications
    www.creativecommunications.ca
    ______________________________

  2. #2
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    First things first you need to snapshot the main timeline into an image:

    Code:
    import flash.display.BitmapData
    var b = new BitmapData(Stage.width,Stage.height)
    b.draw(_root)
    Then when you want to output this as a jpeg you need to send the color of every single pixel to a server-side script which will then build a bitmap file on the server and apply jpeg compression.

    You will be sending quite alot of data over the wire so this could take some time and you will also need to send using HTTP POST.

    I would personally use php and the GD Image Library for the server-side.

    There are potentially alot of pixels that you will need to loop through. Flash will most probably display a "This script is running slowly" if you loop over the pixels all on one frame. So i suggest that you loop over the pixels over a number of frames.

    You can use:

    Code:
    b.getPixel(x,y)
    To get the color of the pixel as the specified location.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center