Adobe Extending Dreamweaver CS4 User Manual

Page 100

Advertising
background image

94

EXTENDING DREAMWEAVER CS4

User interfaces for extensions

<html xmlns:MMStr ing="http://www.adobe.com /schemes/data/ string/">
<head>

<title> Smart Objects API</ title >
<SC RIPT SRC="../Shared/Common/Scripts /dwscripts.js"></SC RIPT>
<SCRIPT LANGUAGE="Javascript">

function invokeSmartObjectJavaScriptAPICall() {

var selection = dw.getSelection();
if (!selection) {
alert("Err: No selection!");
return;
}
var node = dw.offsetsToNode(selection[0], selection[1]);
if (!node) {

alert("Err: No Node!");
return;

}

var imageSrc = node.getAttribute("src");
if (!imageSrc) {

alert("Err: No src attribute!");
return;
}

var fullPath = getFullPath(imageSrc);
if (!fullPath) {

alert("Err: No path!");
return;
}

//alert(fullPath);
alert("updateSmartObjectFromOriginal");
dw.updateSmartObjectFromOriginal(fullPath);

}

<script>

</head>
<body onload="invokeSmartObjectJavaScriptAPICall()">
</body>
</html>

Now, save the file as smartobjects.htm in the application Configuration/Commands folder. When prompted, select the
SWF file in the Commands folder, and click OK.

Advertising
This manual is related to the following products: