Packagecom.candymandesign.image
Classpublic class ImageExport

The ImageExport class converts DisplayObject to ByteArray and export it as valid jpg or png file.

The current version uses as3corelib but if you are on Flex 3, you can import mx.graphics.codec.JPEGEncoder and mx.graphics.codec.PNGEncoder and change just one line of the code in the toJPG function.

In order to see the PHP code, call tracePHP function.

See also

http://candymandesign.blogspot.com
http://code.google.com/p/as3corelib/


Public Methods
 MethodDefined by
  
Constructor.
ImageExport
  
toJPG($source:DisplayObject, $pathToPHP:String, $quality:Number = 80):void
[static] Export DisplayObject to valid JPG file.
ImageExport
  
toPNG($source:DisplayObject, $pathToPHP:String):void
[static] Export DisplayObject to valid PNG file.
ImageExport
  
tracePHP():void
[static] Traces PHP code you will need to use in order to see the result.
ImageExport
Constructor detail
ImageExport()constructor
public function ImageExport()

Constructor.

Method detail
toJPG()method
public static function toJPG($source:DisplayObject, $pathToPHP:String, $quality:Number = 80):void

Export DisplayObject to valid JPG file. Usage example:


   
   import com.candymandesign.image.ImageExport;
   
   var pathToPHPFile:String = "http://localhost/displayImage/display.php";
   ImageExport.toJPG(my_mc, pathToPHPFile, 100);
   
   

Parameters
$source:DisplayObject — - DisplayObject you want to convert to JPG.
 
$pathToPHP:String — - Path to PHP file.
 
$quality:Number (default = 80) — - quality of the exported jpg.
toPNG()method 
public static function toPNG($source:DisplayObject, $pathToPHP:String):void

Export DisplayObject to valid PNG file. Usage example:


   
   import com.candymandesign.image.ImageExport;
   
   var pathToPHPFile:String = "http://localhost/displayImage/display.php";
   ImageExport.toPNG(my_mc, pathToPHPFile);
   
   

Parameters
$source:DisplayObject — - DisplayObject you want to convert to JPG.
 
$pathToPHP:String — - Path to PHP file.
tracePHP()method 
public static function tracePHP():void

Traces PHP code you will need to use in order to see the result. Usage example:


   
   import com.candymandesign.image.ImageExport;
   
   
   ImageExport.tracePHP();//traces PHP code.