com.adobe.icomm.assetplacement.data

# XFADataStream - AS3 Asset Placement

Package | com.adobe.icomm.assetplacement.data
Class | public class XFADataStream
Inheritance | XFADataStream EventDispatcher Object

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 10

XFADataStream is used for asynchronous read/write to the datasets XML packet within the XFA array of a PDF document. The datasets XML is specified in a package definition file by declaring an xml resource with a special reserved id value of "data". This packet represents the data that both the host PDF document and the SWF navigator share. In order to read/write to this packet the application must have initialized the NavigatorHostInstance class by calling
Copy

                 NavigatorHostInstance.initialize(hostValue);

in the handshaking function between the navigator and the host.

View the examples

Related API Elements

com.adobe.portfolio.api.INavigator
com.adobe.portfolio.api.INavigatorHost
Otherwise any calls to read or write to the datasets packet will throw an exception.

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | XFADataStream() Constructor | XFADataStream
|  | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. | EventDispatcher
|  | dispatchEvent(event:Event):Boolean Dispatches an event into the event flow. | EventDispatcher
|  | hasEventListener(type:String):Boolean Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | EventDispatcher
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | readXML():void Asynch call to read the xfadata set xml stream from Acrobat. | XFADataStream
|  | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void Removes a listener from the EventDispatcher object. | EventDispatcher
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object
|  | willTrigger(type:String):Boolean Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | EventDispatcher
|  | writeXML(xml:XML):void Asynch call to save the given XML into the xfadata set stream within Acrobat. | XFADataStream

Events
Click for more information on events
Hide Inherited Events
Show Inherited Events

| Event | Summary | Defined By
--- | --- | --- | ---
|  | activate | [broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active. | EventDispatcher
|  | deactivate | [broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive. | EventDispatcher
|  | xfaDataLoadFailed | Dispatched when the xfadataset xml fails to load | XFADataStream
|  | xfaDataReady | Dispatched when the xfadataset xml is available after calling readXML() | XFADataStream
|  | xfaDataSaved | Dispatched when the xfadataset xml has finished saving after a call to saveData(xml) | XFADataStream
|  | xfaDataSaveFailed | Dispatched when the xfadataset xml has failed to save after a call to saveXML(xml) | XFADataStream

Constructor Detail

### XFADataStream

()
Constructor

`public function XFADataStream()`

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 9, Flash Player 10

Constructor

Method Detail

### readXML

()
method

`public function readXML():void`

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 10

Asynch call to read the xfadata set xml stream from Acrobat. Caller should register for xfaDataReady event as well as xfaDataLoadFailed event. Calling this function before setting NavigatorHostInstance.value throws an error.

### writeXML

()
method

`public function writeXML(xml:XML):void`

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 10

Asynch call to save the given XML into the xfadata set stream within Acrobat. Caller should register for xfaDataSaved and xfaDataSaveFailed events to determine the outcome. The xml passed in must be non-null, otherwise an Error is thrown. Calling this function before setting NavigatorHostInstance.value throws an error.

Parameters

| `xml:XML`

Event Detail

### xfaDataLoadFailed

Event

Event Object Type: `com.adobe.icomm.assetplacement.data.XFADataLoadFailedEvent`
property XFADataLoadFailedEvent.type = `com.adobe.icomm.assetplacement.data.XFADataLoadedEvent.XFA_DATA_LOADFAILED`

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 10

Dispatched when the xfadataset xml fails to load

### xfaDataReady

Event

Event Object Type: `com.adobe.icomm.assetplacement.data.XFADataReadyEvent`
property XFADataReadyEvent.type = `com.adobe.icomm.assetplacement.data.XFADataLoadedEvent.XFA_DATA_LOADED`

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 10

Dispatched when the xfadataset xml is available after calling `readXML()`

### xfaDataSaved

Event

Event Object Type: `com.adobe.icomm.assetplacement.data.XFADataSavedEvent`
property XFADataSavedEvent.type = `com.adobe.icomm.assetplacement.data.XFADataSavedEvent.XFA_DATA_SAVED`

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 10

Dispatched when the xfadataset xml has finished saving after a call to `saveData(xml)`

A value that represents the Event name.

### xfaDataSaveFailed

Event

Event Object Type: `com.adobe.icomm.assetplacement.data.XFADataSaveFailedEvent`
property XFADataSaveFailedEvent.type = `com.adobe.icomm.assetplacement.data.XFADataSaveFailedEvent.XFA_DATA_SAVEFAILED`

Language Version: | ActionScript 3.0

Product Version: | Asset Placement Building Block 10

Runtime Versions: | AIR 1.0, Flash Player 9, Flash Player 10

Dispatched when the xfadataset xml has failed to save after a call to `saveXML(xml)`

A value that represents the Event name.
Examples How to use this example
This class can be used in ActionScript as follows:
Copy

         private xfaStream:XFADataStream = new XFADataStream();

         public function set host(value:INavigatorHost):void
         {
                 if(value)
                 {
                 //
                 //Initialize the navigator.
                 //

                 //Set the host instance to allow centralized access
                 NavigatorHostInstance.initialize(value);

                 //Add handlers for read/write
                 xfaStream.addEventListener(XFADataReadyEvent.XFA_DATA_READY, onXFADataReady);
                 xfaStream.addEventListener(XFADataLoadFailedEvent.XFA_DATA_LOADFAILED, onXFADataLoadFailed);
                 xfaStream.addEventListener(XFADataSavedEvent.XFA_DATA_SAVED, onXFADataSaved);
                 xfaStream.addEventListener(XFADataSaveFailedEvent.XFA_DATA_SAVEFAILED, onXFADataSaveFailed);
             }
             else
             {
                 //
                 //Shutdown the navigator
                 //
                 NavigatorHostInstance.release();

                     //other cleanup ...
                 }
         }

         public function readData() : void
         {
          try
           {
             xfaStream.readXML();
              }
          catch(e:Error)
           {
             //UNEXPECTED ERROR
           }
         }

         public function writeData(newXML:XML) : void
         {
             try
             {
                 xfaStream.writeXML(xml);
             }
             catch(e:Error)
             {
                 //UNEXPECTED ERROR
             }
         }

         //event handler for when xfa data successfully loaded via XFADataStream
         private function onXFADataReady(event:XFADataReadyEvent) : void
         {
             //The xfa data loaded successfully
             var info:XML = event.data;
         }

         //event handler for when xfa data fails to load via XFADataStream
         private function onXFADataLoadFailed(event:XFADataLoadFailedEvent) : void
         {
                 //Failed to load data. See event.error
         }

         //event handler for when xfa data successfully saved via XFADataStream
         private function onXFADataSaved(event:XFADataSavedEvent) : void
         {
                 //The xfa data was saved successfully");
         }

         //event handler for when xfa data fails to save via XFADataStream
         private function onXFADataSaveFailed(event:XFADataSaveFailedEvent) : void
         {
                 //Failure to save data. See event.error
         }

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00