Packagecom.adobe.portfolio.api
Interfacepublic interface IAttachment extends flash.events.IEventDispatcher

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

An individual attachment in the portfolio.



Public Properties
 PropertyDefined By
  children : IList
[read-only] Children of this IAttachment.
IAttachment
  compressedSize : uint
[read-only] The compressed size (in bytes) of the file.
IAttachment
  creationDate : Date
[read-only] The creation date of the file.
IAttachment
  dataUrl : String
[read-only] Returns a url that can be used to load the contents of the attachment file.
IAttachment
  description : String
Sets or gets the file description.
IAttachment
  fileName : String
The last segment of the path property.
IAttachment
  icon : Bitmap
[read-only] Gets the icon representation of the file according to the file type.
IAttachment
  isFolder : Boolean
[read-only] true if this IAttachment represents a folder; false otherwise.
IAttachment
  isOpen : Boolean
[read-only] true if the attachment is open; false otherwise.
IAttachment
  mimeType : String
[read-only] The MIME media type of the attachment data.
IAttachment
  modDate : Date
[read-only] Gets the modification date of the file.
IAttachment
  pageCount : uint
[read-only] Gets the number of pages for an attachment
IAttachment
  pageNumber : uint
Gets/sets the current page number for the attachment currently in focus
IAttachment
  parent : IAttachment
The parent of this IAttachment.
IAttachment
  path : String
[read-only] The attachment's path within the portfolio.
IAttachment
  size : uint
[read-only] Gets the uncompressed size (in bytes) of the file.
IAttachment
Public Methods
 MethodDefined By
  
getFieldPrefix(fieldName:String):String
Retrieves the prefix for a particular field.
IAttachment
  
getFieldStyledText(fieldName:String):XML
For some string field in the collection schema, this function retrieves the IAttachment instance's XML-coded value for that field.
IAttachment
  
getFieldValue(fieldName:String):*
For some field in the collection schema, this function retrieves the IAttachment instance's value for that field.
IAttachment
  
requestCachedThumbnail(id:*, callback:Function):void
Requests the attachment thumbnail that is cached in the portfolio document.
IAttachment
  
requestPageThumbnail(id:*, pageNumber:uint, width:uint, height:uint, callback:Function):void
Requests a thumbnail image for a specific attachment page at a specified size.
IAttachment
  
setFieldPrefix(fieldName:String, value:String):void
Sets the prefix for a particular field.
IAttachment
  
setFieldValue(fieldName:String, value:*):void
Sets the value of a specified field in an IAttachment.
IAttachment
  
writeData(buffer:ByteArray, response:Function = null):void
Replaces the contents of the file attachment This operation is only allowed when the permission "Document"/"Modify" has been granted.
IAttachment
Events
 Event Summary Defined By
  An event that is dispatched for a change to either a schema field value or a schema prefix value.IAttachment
Property Detail
childrenproperty
children:IList  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Children of this IAttachment.

It will be null if this IAttachment is not a folder (for example, if isFolder is false).

Otherwise this is an ordered list (possibly empty) of non-null IAttachment instances. In this case the IList is read-only; attempts to modify it will generate exceptions.


Implementation
    public function get children():IList

See also

mx.collections.IList
compressedSizeproperty 
compressedSize:uint  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

The compressed size (in bytes) of the file.

This property can be used as the source for data binding.


Implementation
    public function get compressedSize():uint
creationDateproperty 
creationDate:Date  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

The creation date of the file. The creation date will never change, so there is no change event associated with this property.


Implementation
    public function get creationDate():Date
dataUrlproperty 
dataUrl:String  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Returns a url that can be used to load the contents of the attachment file.

This property can be used as the source for data binding.


Implementation
    public function get dataUrl():String
descriptionproperty 
description:String

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Sets or gets the file description.

This property can be used as the source for data binding.


Implementation
    public function get description():String
    public function set description(value:String):void

Throws
Error — An Error is thrown if the file description is set when the permission "EmbeddedFile"/"Modify" has not been granted.

See also

fileNameproperty 
fileName:String

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

The last segment of the path property.

This property can be used as the source for data binding.


Implementation
    public function get fileName():String
    public function set fileName(value:String):void

Throws
Error — An Error is thrown if it is set when the permission "EmbeddedFile"/"Modify" has not been granted.

See also

iconproperty 
icon:Bitmap  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Gets the icon representation of the file according to the file type.

The value may be initially null.

This property can be used as the source for data binding.


Implementation
    public function get icon():Bitmap
isFolderproperty 
isFolder:Boolean  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

true if this IAttachment represents a folder; false otherwise.


Implementation
    public function get isFolder():Boolean
isOpenproperty 
isOpen:Boolean  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

true if the attachment is open; false otherwise.

This property can be used as the source for data binding.


Implementation
    public function get isOpen():Boolean
mimeTypeproperty 
mimeType:String  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

The MIME media type of the attachment data.

MIME media type is defined by RFC 2046. Values for this property are as registered by IANA.

This property will be null if and only if the implementation cannot determine the MIME type.

Common values for this property include (but are not limited to):

File Type MIME Type Notes
PDF application/pdf
JPEG image image/jpeg
GIF image image/gif
PNG image image/png
SWF application/x-shockwave-flash This type is not registered with IANA.
Microsoft Word application/msword
Microsoft Excel application/vnd.ms-excel


Implementation
    public function get mimeType():String
modDateproperty 
modDate:Date  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Gets the modification date of the file.

This property can be used as the source for data binding.


Implementation
    public function get modDate():Date
pageCountproperty 
pageCount:uint  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Gets the number of pages for an attachment

This property can be used as the source for data binding.


Implementation
    public function get pageCount():uint
pageNumberproperty 
pageNumber:uint

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Gets/sets the current page number for the attachment currently in focus

This property can be used as the source for data binding.


Implementation
    public function get pageNumber():uint
    public function set pageNumber(value:uint):void
parentproperty 
parent:IAttachment

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

The parent of this IAttachment.

The value must be either null or an IAttachment that represents a folder. A value of null indicates that this IAttachment is located at the root level of the collection's folder hierarchy.

This property can be used as the source for data binding.


Implementation
    public function get parent():IAttachment
    public function set parent(value:IAttachment):void

Throws
Error — An Error is thrown if the value is set to an IAttachment that is not a folder, or if the value is set when the permission "EmbeddedFile"/"Modify" has not been granted.

See also

pathproperty 
path:String  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

The attachment's path within the portfolio.

This property can be used as the source for data binding.


Implementation
    public function get path():String
sizeproperty 
size:uint  [read-only]

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Gets the uncompressed size (in bytes) of the file.

This property can be used as the source for data binding.


Implementation
    public function get size():uint
Method Detail
getFieldPrefix()method
public function getFieldPrefix(fieldName:String):String

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Retrieves the prefix for a particular field.

A field can have a prefix that is not part of the value, but should be presented to the user as if it were. For example, consider an email archive containing subjects with the prefixes "FWD: " or "RE: ". In one case (display) the prefix and the value should be concatenated. In another case (sort comparison) the prefix should be ignored.

Parameters

fieldName:String — The name of the field for which to return the prefix.

Returns
String — The value of the field prefix; it returns "" (an empty String) if there is no prefix. It returns undefined if the field is not part of the collection schema.
getFieldStyledText()method 
public function getFieldStyledText(fieldName:String):XML

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

For some string field in the collection schema, this function retrieves the IAttachment instance's XML-coded value for that field.

A change to the value of a schema property will dispatch a FieldValueChangeEvent. The name of the schema property that changed will be stored in FieldValueChangeEvent.fieldName.

Parameters

fieldName:String — The name of the field.

Returns
XML — The string field's XML-encoded value as Text Layout Format

See also

getFieldValue()method 
public function getFieldValue(fieldName:String):*

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

For some field in the collection schema, this function retrieves the IAttachment instance's value for that field.

A change to the value of a schema property will dispatch a FieldValueChangeEvent. The name of the schema property that changed will be stored in FieldValueChangeEvent.fieldName.

Parameters

fieldName:String — The name of the field.

Returns
* — The field value. Depending on the field type, this will be a String, Number or Date. It returns undefined if the field is not part of the collection schema.

See also

ICollection.fields
String
Number
Date
requestCachedThumbnail()method 
public function requestCachedThumbnail(id:*, callback:Function):void

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Requests the attachment thumbnail that is cached in the portfolio document. In PDF files the cached thumbnail is stored in the attachment's /Thumb dictionary.

Cached thumbnails, when they exist, can typically be returned much more quickly than a bitmap can be generated using requestPageThumbnail().

Cached thumbnail images are generally small, although there is no guarantee as to what specific dimensions they will have.

If there is no cached thumbnail, this method returns a null Bitmap.

The Bitmap is returned via the provided callback function. The callback has the following signature:

function(id:*, bitmap:Bitmap):void
where bitmap is the requested thumbnail.

The callback function is guaranteed to be called exactly once. It is guaranteed to be called asynchronously (outside the scope of this method).

Parameters

id:* — Arbitrary data passed by the caller, typically used to identify the request.
 
callback:Function — Callback function as described above.

requestPageThumbnail()method 
public function requestPageThumbnail(id:*, pageNumber:uint, width:uint, height:uint, callback:Function):void

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Requests a thumbnail image for a specific attachment page at a specified size. This generates a new bitmap dynamically. This typically takes much longer to return a bitmap than requestPageThumbnail().

At least one dimension in the Bitmap will exactly match the request. Neither dimension will exceed the requested size. In the case where one dimension is smaller than requested, it's value will be chosen so as to preserve the content aspect ratio as closely as possible.

If the implementation cannot produce pixels for any reason (unsupported format; can't render requested size; errors; etc.) it returns a null Bitmap.

The Bitmap is returned via the provided callback function. The callback has the following signature:

function(id:*, pageNumber:uint, width:Number, height:Number, bitmap:Bitmap):void
where id, width and height are the corresponding arguments from the method call, and bitmap is the requested thumbnail.

The callback function is guaranteed to be called exactly once. It is guaranteed to be called asynchronously (outside the scope of this method).

Parameters

id:* — Arbitrary data passed by the caller, typically used to identify the request.
 
pageNumber:uint — The attachment page number for the thumbnail, It must be > 0 and <= 2048.
 
width:uint — The width of the thumbnail, in pixels. It must be > 0 and <= 2048.
 
height:uint — The height of the thumbnail, in pixels. It must be > 0 and <= 2048.
 
callback:Function — Callback function as described above.

setFieldPrefix()method 
public function setFieldPrefix(fieldName:String, value:String):void

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Sets the prefix for a particular field.

Parameters

fieldName:String — The name of the field for which to return the prefix.
 
value:String — The value of the field prefix; "" (an empty String) if there is no prefix.


Throws
Error — An Error is thrown if the fieldName argument refers to a non-existent field (that is, a field not in the schema, as reported by ICollection.fields). In addition, an Error is thrown if the field maps to a read-only IAttachment property (that is, the IField has a type of CREATION_DATE, MOD_DATE, COMPRESSED_SIZE, or SIZE). No error is thrown if the field maps to a writable IAttachment property (the IField has an type of DESCRIPTION or FILE_NAME). In addition, an Error is thrown if this method is called when the permission "EmbeddedFile"/"Modify" has not been granted.

See also

setFieldValue()method 
public function setFieldValue(fieldName:String, value:*):void

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Sets the value of a specified field in an IAttachment.

Parameters

fieldName:String — The name of the field.
 
value:* — The field's new value. Depending on the field type, this will be a String, Number, Date, or XML. If the value is XML, then the field is set as styled text, which only applies to a string-typed field. The XML must be in Text Layout Markup.


Throws
Error — An Error is thrown if the fieldName argument refers to a non-existent field (that is, a field not in the schema, as reported by ICollection.fields). In addition, an Error is thrown if the field maps to a read-only IAttachment property (that is, the IField has an type of CREATION_DATE, MOD_DATE, COMPRESSED_SIZE, or SIZE). No error is thrown if the field maps to a writable IAttachment property (the IField has an type of DESCRIPTION or FILE_NAME). Also, an Error is thrown if this method is called when the permission "EmbeddedFile"/"Modify" has not been granted.

See also

writeData()method 
public function writeData(buffer:ByteArray, response:Function = null):void

Language Version : ActionScript 3.0
Product Version : Portfolio 10.0
Runtime Versions : Flash Player 10.1, AIR 2.0

Replaces the contents of the file attachment

This operation is only allowed when the permission "Document"/"Modify" has been granted. A SWF file may not be uploaded.

The maximum length of the ByteArray accepted by this method is 1,048,576 bytes.

Accepts an optional callback function as an argument. When it is non-null, the callback function is invoked to indicate the result of the operation. The callback function receives a single argument, an Object, and has the following signature:

    function callback(response:Object):void
The response parameter contains properties that describe the response. These include:

PropertyTypeValue
'success'Booleantrue if the operation succeeded; false otherwise.
'error'StringA non-human-readable String describing the error. It is non-null only if success is false.

Parameters

buffer:ByteArray — The byte array that contains the buffer that will be written to the file.
 
response:Function (default = null) — An optional notification function, as described above.


Throws
Error — An Error is thrown if the permission "Document"/"Modify" has not been granted.

See also

Event Detail
fieldValueChanged Event
Event Object Type: com.adobe.portfolio.api.FieldValueChangedEvent

Language Version : ActionScript 3.0
Product Version : Portfolio 9.0
Runtime Versions : Flash Player 10.1, AIR 2.0

An event that is dispatched for a change to either a schema field value or a schema prefix value.

See also