Click to See Complete Forum and Search --> : export as image using actionscript
willi-jay
09-25-2005, 07:22 PM
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?
FlashGuru
09-25-2005, 08:13 PM
First things first you need to snapshot the main timeline into an image:
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:
b.getPixel(x,y)
To get the color of the pixel as the specified location.
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.