Packagecom.adobe.kevlar.dispatchers
Classpublic class KevlarMessageDispatcher
InheritanceKevlarMessageDispatcher Inheritance Object

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

The KevlarMessageDispatcher is an abstraction layer on top of the KevlarConnection, which makes it easy to send properly formatted messages to Photoshop. You can either call some of the helper functions that will create and dispatch the messages for you (createNewDocument, requestThumbnail, etc.), or create your own IMessage and call sendMessage().



Public Methods
 MethodDefined By
  
Constructor.
KevlarMessageDispatcher
  
createNewDocument(transactionID:int = -1, width:int = 640, height:int = 480, ppi:int = 72):void
Dispatches a message instructing Photoshop to create a new document with the specified parameters.
KevlarMessageDispatcher
  
requestThumbnail(transactionID:int = -1, width:int = 640, height:int = 480, format:int = 1):void
Dispatches a message requesting that Photoshop return an image of the currently opened document.
KevlarMessageDispatcher
  
sendMessage(message:IMessage):void
Takes an IMessage and sends it to Photoshop.
KevlarMessageDispatcher
Protected Constants
 ConstantDefined By
  MESSAGE_TEXT_DOCUMENTS_ADD : String = documents.add($1, $2, $3)
[static] Creates a new document
KevlarMessageDispatcher
  MESSAGE_TEXT_DOCUMENTS_SEND_THUMBNAIL : String
[static] Requests that Photoshop send us a JPG of the current document
KevlarMessageDispatcher
  MESSAGE_TEXT_SUBSCRIBE_COLOR_FOREGROUND : String
[static] Instructs Photoshop to update us on the foreground color, whenever it's changed
KevlarMessageDispatcher
Constructor Detail
KevlarMessageDispatcher()Constructor
public function KevlarMessageDispatcher(kc:KevlarConnection)

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Constructor. Creates a new KevlarMessageDispatcher.

Parameters
kc:KevlarConnection — The KevlarConnection to use when sending out messages
Method Detail
createNewDocument()method
public function createNewDocument(transactionID:int = -1, width:int = 640, height:int = 480, ppi:int = 72):void

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatches a message instructing Photoshop to create a new document with the specified parameters.

Parameters

transactionID:int (default = -1) — You can override the default value if you wish to send the message with a custom transactionID. If you leave it as -1, the message dispatcher will keep track of transactionIDs for you. It's recommended that you don't mix these two systems, as it might lead to conflicts and unpredictable behavior.
 
width:int (default = 640) — The width of the document to create, in pixels
 
height:int (default = 480) — The height of the document to create, in pixels
 
ppi:int (default = 72) — The density of the document to create, in pixels per inch

requestThumbnail()method 
public function requestThumbnail(transactionID:int = -1, width:int = 640, height:int = 480, format:int = 1):void

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatches a message requesting that Photoshop return an image of the currently opened document.

Parameters

transactionID:int (default = -1) — You can override the default value if you wish to send the message with a custom transactionID. If you leave it as -1, the message dispatcher will keep track of transactionIDs for you. It's recommended that you don't mix these two systems, as it might lead to conflicts and unpredictable behavior.
 
width:int (default = 640) — The width of the returned image, in pixels
 
height:int (default = 480) — The height of the returned image, in pixels
 
format:int (default = 1) — The format of the returned image, according to the Photoshop API. Leaving this as 1 will return a JPG. Passing in other values may have unintended effects, or require that you parse the returned image yourself.

sendMessage()method 
public function sendMessage(message:IMessage):void

Takes an IMessage and sends it to Photoshop. The amount of time this function blocks will vary, depending on the type of message, and its size. It will send the data in an asynchronous manner, but some requisite steps, such as converting a Bitmap to a JPG, may take a short amount of time.

Parameters

message:IMessage — The IMessage Object to send to Photoshop

Constant Detail
MESSAGE_TEXT_DOCUMENTS_ADDConstant
protected static const MESSAGE_TEXT_DOCUMENTS_ADD:String = documents.add($1, $2, $3)

Creates a new document

MESSAGE_TEXT_DOCUMENTS_SEND_THUMBNAILConstant 
protected static const MESSAGE_TEXT_DOCUMENTS_SEND_THUMBNAIL:String

Requests that Photoshop send us a JPG of the current document

MESSAGE_TEXT_SUBSCRIBE_COLOR_FOREGROUNDConstant 
protected static const MESSAGE_TEXT_SUBSCRIBE_COLOR_FOREGROUND:String

Instructs Photoshop to update us on the foreground color, whenever it's changed