BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Saving Image to File System Using Flex 4

Posted by Shardul Singh Bartwal on July 4, 2010

It is possible for us to saving any image to our computer from flex application( without any server code).Below is
the demo application.Please not that this is the feature of the flash player 10. So It will not work if your flash player is
older than flash player 10.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx=""
 xmlns:mx="library://" minWidth="955" minHeight="600">

 private function saveImageToFileSystem():void
 var jPEGEncoder:JPEGEncoder = new JPEGEncoder(500);
 var imageSnapshot:ImageSnapshot = ImageSnapshot.captureImage(imgCanvas, 0, jPEGEncoder);
 var fileReference:FileReference = new FileReference();, "img123.jpg");

<mx:VBox horizontalAlign="center" verticalAlign="middle">
<mx:Canvas id="imgCanvas">
<mx:Image source="images/image1.jpg"/>
 <s:Button click="saveImageToFileSystem()" label="Save Image"/>



4 Responses to “Saving Image to File System Using Flex 4”

  1. Chris said

    How would this work for multiple images? E.g. the user clicks the button once and N different images are downloaded to the same destination?

    • shardulbartwal said

      This will not work for multiple images at one time according to the Security measures of the flash player.This feature is totally different from the download.
      And for every file one will require the human interaction by clicking on a button.

  2. Christian said

    The example above specifies a quality parameter of 500. According to the current documentation, “Parameters – quality:Number (default = 50.0) — A value between 0.0 and 100.0. The smaller the quality value, the smaller the file size of the resultant image. The value does not affect the encoding speed. Note that even though this value is a number between 0.0 and 100.0, it does not represent a percentage. The default value is 50.0.” Helpful post though. Very grateful.

  3. said

    It’s going to be ending of mine day, but before end I
    am reading this wonderful article to improve my experience.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: