ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
ObjectEncoding

Package | flash.net
Class | public final class ObjectEncoding
Inheritance | ObjectEncoding Object

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

The ObjectEncoding class allows classes that serialize objects (such as NetStream, NetConnection, SharedObject, and ByteArray) to work with prior versions of ActionScript.

Object encoding controls how objects are represented in Action Message Format (AMF). Flash Player uses AMF to enable efficient communication between a Flash application and a remote server. AMF encodes remote procedure calls into a compact binary representation that can be transferred over HTTP/HTTPS or the RTMP/RTMPS protocol used by Flash Media Server. ActionScript objects and data values are serialized into this binary format, which is generally more compact than other representations, such as XML.

Flash Player 9 can serialize in two different formats, AMF3 and AMF0. AMF3, the default serialization used for ActionScript 3.0, provides various advantages over AMF0, which is used for ActionScript 1.0 and 2.0. AMF3 sends data over the network more efficiently than AMF0. AMF3 supports sending `int` and `uint` objects as integers and supports data types that are available only in ActionScript 3.0, such as ByteArray, XML, and IExternalizable. It is available only in ActionScript 3.0 and with servers that use AMF3 encoding, such as Flex 2.

The ByteArray, NetConnection, NetStream, SharedObject, Socket, and URLStream classes contain an `objectEncoding` property that is assigned a constant from the ObjectEncoding class. The behavior of the `objectEncoding` property differs depending on the object; each class's `objectEncoding` property description explains the behavior more thoroughly.

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
|  | dynamicPropertyWriter : IDynamicPropertyWriter [static] Allows greater control over the serialization of dynamic properties of dynamic objects. | ObjectEncoding
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | 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
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Public Constants

| Constant | Defined By
--- | --- | ---
|  | AMF0 : uint = 0 [static] Specifies that objects are serialized using the Action Message Format for ActionScript 1.0 and 2.0. | ObjectEncoding
|  | AMF3 : uint = 3 [static] Specifies that objects are serialized using the Action Message Format for ActionScript 3.0. | ObjectEncoding
|  | DEFAULT : uint = 3 [static] Specifies the default (latest) format for the current player. | ObjectEncoding

Property Detail

dynamicPropertyWriter | property

`dynamicPropertyWriter:IDynamicPropertyWriter` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Allows greater control over the serialization of dynamic properties of dynamic objects. When this property is set to `null`, the default value, dynamic properties are serialized using native code, which writes all dynamic properties excluding those whose value is a function.

This value is called only for properties of a dynamic object (objects declared within a dynamic class) or for objects declared using the `new` operator.

You can use this property to exclude properties of dynamic objects from serialization; to write values to properties of dynamic objects; or to create new properties for dynamic objects. To do so, set this property to an object that implements the IDynamicPropertyWriter interface. For more information, see the IDynamicPropertyWriter interface.

Implementation
`public static function get dynamicPropertyWriter():IDynamicPropertyWriter`
`public function set dynamicPropertyWriter(value:IDynamicPropertyWriter):void`

See also

IDynamicPropertyWriter
Constant Detail

AMF0 | Constant

`public static const AMF0:uint = 0`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Specifies that objects are serialized using the Action Message Format for ActionScript 1.0 and 2.0.

AMF3 | Constant |

`public static const AMF3:uint = 3`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Specifies that objects are serialized using the Action Message Format for ActionScript 3.0.

DEFAULT | Constant |

`public static const DEFAULT:uint = 3`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Specifies the default (latest) format for the current player. Because object encoding control is only available in Flash® Player 9 and later, the earliest format used will be the Action Message Format for ActionScript 3.0.

For example, if an object has the `objectEncoding` property set to `flash.net.ObjectEncoding.DEFAULT`, Flash Player uses AMF3 encoding. If, in the future, a later version of Flash Player introduces a new AMF version and you republish your content, the player will use that new AMF version. You can use this constant only if you're not concerned at all about interoperability with previous versions of Flash Player.

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00