Packagecom.yworks.remote
Classpublic class ImageExportHandler
InheritanceImageExportHandler Inheritance flash.events.EventDispatcher

A handler that will create a bitmap representation of the canvas content and upload it to the server. The server is expected to respond with a file stream, so the exported image can be saved on the client.



Public Properties
 PropertyDefined By
  additionalParameters : Object
Get or set an object containing additional parameters that will be transfered to the service URL.
ImageExportHandler
  maxImageSize : ISize
Get or set the maximum allowed image size.
ImageExportHandler
Public Methods
 MethodDefined By
  
ImageExportHandler(downloadURL:String)
Creates a new export handler that will use the given downloadURL to download the exported images.
ImageExportHandler
  
export(canvas:CanvasComponent, defaultFileName:String, exportOptions:ExportOptions = null):void
Calls the URL that was passed upon initialization.
ImageExportHandler
Protected Methods
 MethodDefined By
  
createURLRequest(downloadURL:String):URLRequest
Create the URLRequest instance that will be used for the download request.
ImageExportHandler
  
createURLVariables(canvas:CanvasComponent, exportOptions:ExportOptions):URLVariables
Create the URL variables that will be sent to the server.
ImageExportHandler
  
decorateExportSprite(sprite:Sprite, m:Matrix, exportOptions:ExportOptions, canvas:CanvasComponent):void
Callback that allows additional painting on the sprite that will be exported as a bitmap.
ImageExportHandler
  
encodeBitmap(bitmap:BitmapData):ByteArray
Encodes the given bitmap data to a byte array.
ImageExportHandler
  
getImageData(canvas:CanvasComponent, exportOptions:ExportOptions):BitmapData
Draws the canvas contents to a BitmapData instance.
ImageExportHandler
  
onCancel(event:Event):void
Called when the user chose the cancel button of the download dialog.
ImageExportHandler
  
onComplete(evt:Event):void
Called when the export operation has finished succesfully.
ImageExportHandler
  
onHTTPStatus(evt:HTTPStatusEvent):void
Called when the server sends a HTTP status.
ImageExportHandler
  
onIOError(evt:IOErrorEvent):void
Called when an IO error occurs while executing the image file download.
ImageExportHandler
  
onSecurityError(evt:SecurityErrorEvent):void
Called when a security error occurs while executing the image file download.
ImageExportHandler
  
onSelect(evt:Event):void
Called when the user has selected a location for the image file download.
ImageExportHandler
Property Detail
additionalParametersproperty
additionalParameters:Object

Get or set an object containing additional parameters that will be transfered to the service URL.


Implementation
    public function get additionalParameters():Object
    public function set additionalParameters(value:Object):void
maxImageSizeproperty 
maxImageSize:ISize

Get or set the maximum allowed image size.

The size of the exported image will not exceed the size defined by this property.

Note that the maximum size should not be larger than 2880x2880, the maximum allowed size of a BitmapData instance.


Implementation
    public function get maxImageSize():ISize
    public function set maxImageSize(value:ISize):void

See also

flash.display.BitmapData
Constructor Detail
ImageExportHandler()Constructor
public function ImageExportHandler(downloadURL:String)

Creates a new export handler that will use the given downloadURL to download the exported images.

Parameters
downloadURL:String
Method Detail
createURLRequest()method
protected function createURLRequest(downloadURL:String):URLRequest

Create the URLRequest instance that will be used for the download request.

Parameters

downloadURL:String — The service URL that was passed upon initialization.

Returns
URLRequest — An URLRequest instance that will be used in the download method.
createURLVariables()method 
protected function createURLVariables(canvas:CanvasComponent, exportOptions:ExportOptions):URLVariables

Create the URL variables that will be sent to the server.

The default key name that is used for the image url variable is "exportData".

Parameters

canvas:CanvasComponent — The canvas that should be exported to a bitmap.
 
exportOptions:ExportOptions — The export options for this export.

Returns
URLVariables — The URL variables that will be send to the server.

See also

decorateExportSprite()method 
protected function decorateExportSprite(sprite:Sprite, m:Matrix, exportOptions:ExportOptions, canvas:CanvasComponent):void

Callback that allows additional painting on the sprite that will be exported as a bitmap.

Parameters

sprite:Sprite — The sprite that will be exported as a bitmap. The canvas has already been painted on a child display object of the passed Sprite.
 
m:Matrix — The matrix that is used to scale, rotate, or translate the coordinates of the bitmap. The matrix is already configured according to the scaleMode set on the exportOptions parameter.
 
exportOptions:ExportOptions — The export options.
 
canvas:CanvasComponent — The canvas that should be exported to a bitmap.

encodeBitmap()method 
protected function encodeBitmap(bitmap:BitmapData):ByteArray

Encodes the given bitmap data to a byte array.

The default implementation uses PNG encoding.

Parameters

bitmap:BitmapData — The bitmap data to be encoded

Returns
ByteArray — A byte array containing the encoded bitmap data.
export()method 
public function export(canvas:CanvasComponent, defaultFileName:String, exportOptions:ExportOptions = null):void

Calls the URL that was passed upon initialization.

Event handling can be customized by overriding the various protected event handler functions.

Parameters

canvas:CanvasComponent — The graph instance that is to be serialized.
 
defaultFileName:String — The default file name to be shown in the browser's download dialog.
 
exportOptions:ExportOptions (default = null)

getImageData()method 
protected function getImageData(canvas:CanvasComponent, exportOptions:ExportOptions):BitmapData

Draws the canvas contents to a BitmapData instance.

Parameters

canvas:CanvasComponent — The canvas that is to be exported to a bitmap.
 
exportOptions:ExportOptions — The export options.

Returns
BitmapData — A bitmap representation of the current canvas contents.
onCancel()method 
protected function onCancel(event:Event):void

Called when the user chose the cancel button of the download dialog.

Parameters

event:Event

onComplete()method 
protected function onComplete(evt:Event):void

Called when the export operation has finished succesfully.

This implementation removes the busy cursor.

Parameters

evt:Event

onHTTPStatus()method 
protected function onHTTPStatus(evt:HTTPStatusEvent):void

Called when the server sends a HTTP status.

This implementation is empty.

Parameters

evt:HTTPStatusEvent

onIOError()method 
protected function onIOError(evt:IOErrorEvent):void

Called when an IO error occurs while executing the image file download.

This implementation shows an alert message, traces the event and removes the busy cursor.

Parameters

evt:IOErrorEvent

onSecurityError()method 
protected function onSecurityError(evt:SecurityErrorEvent):void

Called when a security error occurs while executing the image file download.

This implementation shows an alert message, traces the event and removes the busy cursor.

Parameters

evt:SecurityErrorEvent

onSelect()method 
protected function onSelect(evt:Event):void

Called when the user has selected a location for the image file download.

This implementation sets the busy cursor.

Parameters

evt:Event