document.setPublishDocumentData()

#### Availability

Adobe Animate.

#### Usage

document.setPublishDocumentData(format, publish)

#### Parameters

format: A string that specifies the publishing format.
Note: _EMBED_SWF_ is a special built-in publishing format for persistent data. If set, the persistent data will be embedded in the SWF file every time a document is published. The persistent data can then be accessed via ActionScript with the .metaData property. This requires SWF version 19 (Flash Player 11.6) and above and is only for symbol instances onstage. Other custom publishing formats may be specified for custom JSFL scripts if this method is called with the same format.

publish: A boolean that indicates whether to enable or disable publishing of persistent data for the specified format. None.

#### Returns

None.

#### Description

Method; Enables or disables publishing of persistent data for an entire document.

#### Example

javascript
The following example illustrates the use of this method:
var doc = fl.getDocumentDOM();
// set the data
 if (doc) {
// get the first selected element
var elem = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0]; 
if (elem) {
// add persistent data "myAlign" of "left"
elem.setPersistentData( "myAlign", "string", "left" );
// enable publishing of persistent data to SWF for the element 
elem.setPublishPersistentData("myAlign", "_EMBED_SWF_", true);
// enable publishing to SWF for entire document 
doc.setPublishDocumentData("_EMBED_SWF_", true);
}
}
// example getting data
if (doc && doc.getPublishDocumentData("_EMBED_SWF_")) {
// get the first selected element
var elem = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0];
if (elem && elem.hasPersistentData("myAlign") && elem.getPublishPersistentData("myAlign", "_EMBED_SWF_")) {
alert("elem.metaData.myAlign = '" + elem.getPersistentData("myAlign") + "' will be embedded in SWF when published.");
}
}


#### See also

document.getPublishDocumentData() (../Document_object/docume83.md)