Save Flex chart as image

Sometime we want to export the charts generated in Adobe Flex to an image. In this article we would learn how we can export Adobe Flex UIComponent to image(JPEG) from your flex application.

public static function exportChartImage(obj:UIComponent):void {
    try{
      var file:FileReference = new FileReference();
      var bmpd:BitmapData = new BitmapData(obj.width, obj.height);
      bmpd.draw(obj);
 
      var jpgenc:JPEGEncoder = new JPEGEncoder(80);
      var imgByteArray:ByteArray = jpgenc.encode(bmpd);
 
      file.save(imgByteArray,"chart.jpg");
    }
    catch(e:Error){}
}


Related Articles:

About Hitesh Agrawal

Wait... checking
Tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>