element.setPublishPersistentData()
#### Availability
Flash Professional CC
#### Usage
element.setPublishPersistentData(name, format, publish)
#### Parameters
name A string that specifies the name of the persistent data item (set with element.setPersistentData() (../Element_object/elemen17.md)).
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.
#### Returns
None.
#### Description
Method; Enables or disables publishing of persistent data for a specified format.
#### 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
element.getPublishPersistentData() (../Element_object/element3.md)