Adobe 38040334 - Dreamweaver CS3 User Manual page 235

Extending dreamweaver
Hide thumbs Also See for 38040334 - Dreamweaver CS3:
Table of Contents

Advertisement

To help avoid performance penalties, use the
function takes two arguments: the JavaScript to be called and the amount of time in milliseconds to wait before
calling it.
The
method lets you build pauses into your processing. These pauses let the user continue inter-
setTimeout()
acting with the application. You must build in these pauses explicitly because the screen freezes while scripts process,
which prevents the user from performing further edits. The pauses also prevent you from updating the interface or
the floating panel.
The following example is from a floating panel that displays information about every
It uses the
setTimeout()
/* create a flag that specifies whether an edit is being processed, and set it to false.*/
document.running = false;
/* this function called when document is edited */
function documentEdited(){
/* create a list of all the AP elements to be processed */
var dom = dw.getDocumentDOM();
document.layers = dom.getElementsByTagName("layer");
document.numLayers = document.layers.length;
document.numProcessed = 0;
/* set a timer to call processLayer(); if we didn't get
* to finish processing the previous edit, then the timer
* is already set. */
if (document.running = false){
setTimeout("processLayer()", 500);
}
/* set the processing flag to true */
document.running = true;
}
/* process one AP element*/
function processLayer(){
/* display information for the next unprocessed AP element.
displayLayer() is a function you would write to
perform the "magic".0*/
displayLayer(document.layers[document.numProcessed]);
/* if there's more work to do, set a timeout to process
* the next layer.0.If we're finished, set the document.running
* flag to false. */
document.numProcessed = document.numProcessed + 1;
if (document.numProcessed < document.numLayers){
setTimeout("processLayer()", 500);
}else{
document.running = false;
}
}
setTimeout()
method to pause for a half second after processing each AP
function. As in the browsers, the
AP element in the document.
element .
DREAMWEAVER CS3
Extending Dreamweaver
setTimeout()
229

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents