ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
com.adobe.icomm.assetplacement.data 

XFADataStream  - AS3 Asset Placement

Packagecom.adobe.icomm.assetplacement.data
Classpublic class XFADataStream
InheritanceXFADataStream Inheritance EventDispatcher Inheritance 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
             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
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
Public Methods
 MethodDefined By
  
Constructor
XFADataStream
 Inherited
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
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
Asynch call to read the xfadata set xml stream from Acrobat.
XFADataStream
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
  
Asynch call to save the given XML into the xfadata set stream within Acrobat.
XFADataStream
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when the xfadataset xml fails to loadXFADataStream
  Dispatched when the xfadataset xml is available after calling readXML()XFADataStream
  Dispatched when the xfadataset xml has finished saving after a call to saveData(xml)XFADataStream
  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.
This class can be used in ActionScript as follows:
     
     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
     }