EDOBE XDOM TAKE 6 IR - PRODUCTSHEET Especificações Página 176

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 304
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 175
CHAPTER 5: Interapplication Communication with Scripts Communicating through messages 176
}
}
Example: Setting up a sender to receive multiple responses
This example sends a message of the type
iterator, to be handled by the onReceive handler in the
previous example, and processes the responses received from that target.
The sending application creates a message whose script (contained in the
body string) iterates through all
files in a specific folder (represented by an Adobe Bridge
Thumbnail object), using the iterator variable i.
For each file in the folder, it returns file size data. For each contained folder, it returns -1. The last executed
line in the script is the final result value for the message.
The onResult
method of the message object receives each intermediate result, stores it into an array,
resArr, and processes it immediately using a script-defined function processInterResult.
// Code for send message and handling response
// in the sending application (any message-enabled application)
var idx = 0;
var resArr = new Array;
bt = new BridgeTalk;
bt.target = "bridge";
bt.type = "iterator";
bt.body = "
var fld = new Thumbnail(Folder(’C/Junk’));
if (i == (fld.children.length - 1))
done = true; //no more files, end loop
tn = fld.children[i];
if (tn.spec.constructor.name == ’File’)
md = tn.core.immediate.size;
else md = -1;
";
// store intermediate results
bt.onResult = function(rObj) {
resArr[idx] = rObj.body;
processInterResult(resArr[idx]);
idx++;};
bt.onError = function(eObj) {
bt.error = eObj.body };
bt.send();
Passing values between applications
The BridgeTalk.onReceive static callback function can return values of any type. The messaging
framework, however, packages the response into a response message, and passes any returned values in
the message
body, first converting the result to a UTF-8-encoded string.
Vista de página 175
1 2 ... 171 172 173 174 175 176 177 178 179 180 181 ... 303 304

Comentários a estes Manuais

Sem comentários