The SubscriptionManager gives you an easy way to get data from Photoshop that pertains to things like color changes, changed tools or settings, and other user events.
For example, if you add an event listener for a SubscriptionEvent.FOREGROUND_COLOR_CHANGE_EVENT, you'll receive a SubscriptionEvent.FOREGROUND_COLOR_CHANGE_EVENT whenever the user changes the foreground color
in Photoshop. (Assuming that the API is able to successfully send the subscription message to Photoshop. This requires that you set up the PhotoshopConnection properly.)
You may attach event listeners for any type of SubscriptionEvent, and the SubscriptionManager will make the required calls to Photoshop to set up (or deactivate) the subscription.
pc:PhotoshopConnection — The PhotoshopConnection that the SubscriptionManager should use when sending subscription-related data. Note that setting this parameter will also set the SubscriptionManager
property inside of the PhotoshopConnection. Thus, as soon as you create this SubscriptionManager, the PhotoshopConnection that you pass in will use it for all future parsing of subscription-related data.
If you have highly customized logic that somehow involves using multiple SubscriptionManagers and/or PhotoshopConenctions, you should restore the pc.subscriptionManager property to its previous value.
Method Detail
addEventListener
()
method
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Language Version :
ActionScript 3.0
Runtime Versions :
AIR 1.0, Flash Player 10
Attaches an event listener of the given type. If this type is a SubscriptionEvent, this function will send the necessary messages to Photoshop to indicate that you wish to subscribe.
Parameters
type:String
listener:Function
useCapture:Boolean (default = false)
priority:int (default = 0)
useWeakReference:Boolean (default = false)
handleSubscriptionTextMessage
()
method
public function handleSubscriptionTextMessage(tm:TextMessage):void
Language Version :
ActionScript 3.0
Runtime Versions :
AIR 1.0, Flash Player 10
Handles a subscription-related text message response from Photoshop. Unless you are manually creating TextMessages (perhaps based on raw data you receive from Photoshop),
you should not need to call this function.
Parameters
tm:TextMessage — The TextMessage that contains text information pertaining to a subscription-related Photoshop event
isSubcribedByTransactionID
()
method
public function isSubcribedByTransactionID(transactionID:int):Boolean
Language Version :
ActionScript 3.0
Runtime Versions :
AIR 1.0, Flash Player 10
Determines if the SubscriptionManager is subscribed, based on the transactionID. The transactionID is how both Photoshop and this API keep track of the mapping
between events and subscriptions.
Parameters
transactionID:int — The transactionID that you want to check
Returns
Boolean — Returns true if this transactionID is mapped to an active subscription
isSubscribedBySubscriptionType
()
method
public function isSubscribedBySubscriptionType(subscriptionType:int):Boolean
Language Version :
ActionScript 3.0
Runtime Versions :
AIR 1.0, Flash Player 10
Determines if the SubscriptionManager is subscribed, based on the type of subscriptiopn
Parameters
subscriptionType:int — The Type of subscription that you want to check
Returns
Boolean — Returns true if you're currently subscribed to this type of subscription
removeEventListener
()
method
override public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Language Version :
ActionScript 3.0
Runtime Versions :
AIR 1.0, Flash Player 10
Removes an event listener of the given type. If this type is a SubscriptionEvent, this function will send the necessary messages to Photoshop to indicate that you wish to unsubscribe.