EDOBE XDOM TAKE 6 IR - PRODUCTSHEET Specifikace Strana 172

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 304
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 171
CHAPTER 5: Interapplication Communication with Scripts Communicating through messages 172
var targetApp = BridgeTalk.getSpecifier( "bridge-3.0");
if( targetApp ) {
// construct a message object
var bt = new BridgeTalk;
// the message is intended for Adobe Bridge CS4
bt.target = targetApp;
// the script to evaluate is contained in a string in the "body" property
bt.body = "new Document(’C:\\BridgeScripts’);
app.document.target.children.length;"
// define result handler callback
bt.onResult = function(returnBtObj) {
processResult(returnBtObj.body); } //fn defined elsewhere
// send the message asynchronously
bt.send();
}
Receiving messages
An application can be the target of a message; that is, it receives an unsolicited message from another
application. An unsolicited message is handled by the static
BridgeTalk.onReceive callback function in
the target application. See
Handling unsolicited messages” on page 172.
An application that sends a message can receive response messages; that is, messages that come as the
result of requesting a response when a message was sent. These can be:
X The result of an error in processing the message
X The result of a timeout when attempting to process the message
X A notification of receipt of the message
X Intermediate responses
X The final result of processing the message.
All of these response messages are sent automatically by the target application, and are handled by
callbacks defined in the sending message object. For details, see
Handling responses from the message
target” on page 173.
Handling unsolicited messages
To specify how the application should handle unsolicited incoming messages, define a callback handler
function in the static onReceive
property of the BridgeTalk class. This function takes a single argument, a
BridgeTalk message object
.
The default behavior of the
onReceive handler is to evaluate the body of the received message with
JavaScript, and return the result of that evaluation. (The result of evaluating a script is the result of the last
line of the script.) To return the result, it creates a new message object, encapsulates the result in a string in
the
body property of that object, and passes that object to the onResult callback defined in the original
message.
If an error occurs on evaluation, the default
onReceive handler returns the error information using a
similar mechanism. It creates a new message object, encapsulates the error information in a string in the
body property of that object, and passes that object to the onError callback defined in the original
message.
Zobrazit stránku 171
1 2 ... 167 168 169 170 171 172 173 174 175 176 177 ... 303 304

Komentáře k této Příručce

Žádné komentáře