Export PNG From Flash Using ActionScript 3 PNG Exporter Class

Author: Muhammad bin Yusrat

Description: Makes an easy to export PNG Images from with in Flash. You can take a snapshot of any MovieClip and get the class to export it to PHP which then saves it.

Functions:

snapObject(target:MovieClip,cropArea:Rectangle = null)
This function accepts two arguments. One the target MovieClip that needs to be snapped. Second is an optional Rectangle (flash.geom.Rectangle) which, if passed, will crop the image to that rectangle.
SendToPage(URLToPage:String,onComplete:Function = null)
Once the movieclip has been snapped you can simply call this function and give it the URL to the PHP Page (included in the files) and it will send the image to it. A option “onComplete” function can also be passed which will be called once the image is saved.

Sample Code:

import com.muhammadbinyusrat.PNGExport;
var SnapObject:PNGExport = new PNGExport();//instanciate the class
SnapObject.snapObject(testClip); /*Takes a snapshot of the provided MovieClip, if you want it to be cropped before sending, you can specify a second argument as Rectangle*/
SnapObject.SendToPage(“http://localhost/class/GetImage.php“,test);
/*Once snaped, it can be sent to any page. The second argument is the function that can be called once the processing complete. Second argument is optional. */
function test(e:Event):void{
trace(“PHP’s Response:” + e.target.data);
}

Download:
PNGExport.zip

No related posts.


Trackbacks & Pingbacks

No trackbacks/pingbacks yet.

Comments

Can this tool create images in 300 DPI? How is this useful for flash applications that generate graphics for print?

Is there a flash tool out there that can produce print quality graphics?

The class has been updated to V2. You should rather link to the original page as well so that people see the most up-to-date version of the class.

Leave a comment

(required)

(required)