PackageTop Level
Classpublic dynamic class Object
SubclassesAccessibility, AccessibilityImplementation, AccessibilityProperties, ActionScriptVersion, AntiAliasType, ApplicationDomain, arguments, Array, AudioDecoder, AudioOutputChangeReason, AudioPlaybackMode, AuthenticationMethod, AutoCapitalize, BitmapData, BitmapDataChannel, BitmapEncodingColorSpace, BitmapFilter, BitmapFilterQuality, BitmapFilterType, BlendMode, Boolean, BreakOpportunity, ByteArray, CameraPosition, CameraRollBrowseOptions, Capabilities, CapsStyle, CertificateStatus, CFFHinting, Class, Clipboard, ClipboardFormats, ClipboardTransferMode, Collator, CollatorMode, ColorCorrection, ColorCorrectionSupport, ColorTransform, CompositionAttributeRange, CompressionAlgorithm, Condition, ContentElement, Context3DBlendFactor, Context3DBufferUsage, Context3DClearMask, Context3DCompareMode, Context3DFillMode, Context3DMipFilter, Context3DProfile, Context3DProgramType, Context3DRenderMode, Context3DStencilAction, Context3DTextureFilter, Context3DTextureFormat, Context3DTriangleFace, Context3DVertexBufferFormat, Context3DWrapMode, ContextMenuBuiltInItems, ContextMenuClipboardItems, CSMSettings, CurrencyFormatter, CurrencyParseResult, Date, DateTimeFormatter, DateTimeNameContext, DateTimeNameStyle, DateTimeStyle, Dictionary, Digest, DigitCase, DigitWidth, DisplacementMapFilterMode, DRMContentData, DRMDeviceGroup, DRMPlaybackTimeWindow, DRMVoucher, ElementFormat, EncryptedLocalStore, Encryption, Endian, Error, Event, EventDispatcher, EventPhase, ExtensionInfo, ExternalInterface, FileFilter, FileMode, float, FocusDirection, Font, FontDescription, FontLookup, FontMetrics, FontPosture, FontStyle, FontType, FontWeight, Function, GameInputDevice, GesturePhase, GradientType, Graphics, GraphicsBitmapFill, GraphicsEndFill, GraphicsGradientFill, GraphicsPath, GraphicsPathCommand, GraphicsPathWinding, GraphicsShaderFill, GraphicsSolidFill, GraphicsStroke, GraphicsTrianglePath, GridFitType, GroupSpecifier, H264Level, H264Profile, HTMLHistoryItem, HTMLHost, HTMLPDFCapability, HTMLSWFCapability, HTMLWindowCreateOptions, ID3Info, ImageDecodingPolicy, IMEConversionMode, IndexBuffer3D, int, InterfaceAddress, InterpolationMethod, InvokeEventReason, IPVersion, JointStyle, JPEGEncoderOptions, JPEGXREncoderOptions, JSON, JustificationStyle, Kerning, Keyboard, KeyboardType, KeyLocation, LastOperationStatus, LigatureLevel, LineJustification, LineScaleMode, LoaderContext, LoadVoucherSetting, LocaleID, Math, Matrix, Matrix3D, MediaType, MessageChannelState, MicrophoneEnhancedMode, MicrophoneEnhancedOptions, Mouse, MouseCursor, MouseCursorData, Multitouch, MultitouchInputMode, Mutex, Namespace, NationalDigitsType, NativeDragActions, NativeDragManager, NativeDragOptions, NativeProcessStartupInfo, NativeWindowDisplayState, NativeWindowInitOptions, NativeWindowRenderMode, NativeWindowResize, NativeWindowSystemChrome, NativeWindowType, NetGroupInfo, NetGroupReceiveMode, NetGroupReplicationStrategy, NetGroupSendMode, NetGroupSendResult, NetStreamAppendBytesAction, NetStreamInfo, NetStreamMulticastInfo, NetStreamPlayTransitions, NetworkInterface, NotificationStyle, NotificationType, Number, NumberFormatter, NumberParseResult, Object, ObjectEncoding, Orientation3D, PaperSize, PermissionStatus, PerspectiveProjection, PixelSnapping, PNGEncoderOptions, Point, PrintJobOptions, PrintJobOrientation, PrintMethod, PrintUIOptions, Program3D, Proxy, QName, Rectangle, ReferencesValidationSetting, RegExp, RemoteNotifierSubscribeOptions, RenderingMode, ResourceRecord, Responder, ReturnKeyLabel, RevocationCheckSettings, Scene, ScreenMode, Security, SecurityDomain, SecurityPanel, Shader, ShaderData, ShaderInput, ShaderParameter, ShaderParameterType, ShaderPrecision, SharedObjectFlushStatus, SignatureStatus, SignerTrustSettings, SoftKeyboardTrigger, SoftKeyboardType, SoundCodec, SoundLoaderContext, SoundMixer, SoundTransform, SpreadMethod, SQLCollationType, SQLColumnNameStyle, SQLColumnSchema, SQLErrorOperation, SQLMode, SQLResult, SQLSchema, SQLSchemaResult, SQLTransactionLockType, StageAlign, StageAspectRatio, StageDisplayState, StageOrientation, StageQuality, StageScaleMode, StageTextClearButtonMode, StageTextContentType, StageTextInitOptions, StageVideoAvailability, StageVideoAvailabilityReason, StorageVolume, String, StringTools, SWFVersion, System, SystemIdleMode, SystemUpdaterType, TabAlignment, TabStop, Telemetry, TextBaseline, TextBlock, TextColorType, TextDisplayMode, TextExtent, TextFieldAutoSize, TextFieldType, TextFormat, TextFormatAlign, TextInteractionMode, TextJustifier, TextLineCreationResult, TextLineMetrics, TextLineMirrorRegion, TextLineValidity, TextRenderer, TextRotation, TextSnapshot, ThrottleType, TimeZone, TouchEventIntent, TouchscreenType, Transform, TriangleCulling, TypographicCase, uint, Updater, URLLoaderDataFormat, URLRequest, URLRequestDefaults, URLRequestHeader, URLRequestMethod, URLVariables, Utils3D, Vector, Vector3D, VertexBuffer3D, VideoCodec, VideoStatus, VideoStreamSettings, VoucherAccessInfo, WorkerDomain, WorkerState, X500DistinguishedName, X509Certificate, XML, XMLList, XMLNode, XMLNodeType, ZipEntry

Runtime version: AIR 1.0

The Object class is at the root of the ActionScript runtime class hierarchy. Objects are created by constructors using the new operator syntax, and can have properties assigned to them dynamically. Objects can also be created by assigning an object literal, as in:
var obj:Object = {a:"foo", b:"bar"}

All classes that don't declare an explicit base class extend the built-in Object class.

All runtime classes in the Adobe Integrated Runtime extend the runtime.Object class.

You can use the Object class to create associative arrays. At its core, an associative array is an instance of the Object class, and each key-value pair is represented by a property and its value. Another reason to declare an associative array using the Object data type is that you can then use an object literal to populate your associative array (but only at the time you declare it). The following example creates an associative array using an object literal, accesses items using both the dot operator and the array access operator, and then adds a new key-value pair by creating a new property:


 var myAssocArray:Object = {fname:"John", lname:"Public"};

 trace(myAssocArray.fname);     // John

 trace(myAssocArray["lname"]);  // Public

 myAssocArray.initial = "Q";

 trace(myAssocArray.initial);   // Q

ActionScript 3.0 has two types of inheritance: class inheritance and prototype inheritance:

Both class inheritance and prototype inheritance can exist simultaneously, as shown in the following example:


 class A {

     var x = 1

     prototype.px = 2

 }

 dynamic class B extends A {

     var y = 3

     prototype.py = 4

 }

  

 var b = new B()

 b.x // 1 via class inheritance

 b.px // 2 via prototype inheritance from A.prototype

 b.y // 3

 b.py // 4 via prototype inheritance from B.prototype

  

 B.prototype.px = 5

 b.px // now 5 because B.prototype hides A.prototype

  

 b.px = 6

 b.px // now 6 because b hides B.prototype

Using functions instead of classes, you can construct custom prototype inheritance trees. With classes, the prototype inheritance tree mirrors the class inheritance tree. However, since the prototype objects are dynamic, you can add and delete prototype-based properties at run time.

View the examples.

See also

prototype


Public Properties
 PropertyDefined by
  constructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  prototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined by
  
Creates an Object object and stores a reference to the object's constructor method in the object's constructor property.
Object
  
Indicates whether an object has a specified property defined.
Object
  
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
Indicates whether the specified property exists and is enumerable.
Object
  
Sets the availability of a dynamic property for loop operations.
Object
  
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
  
Returns the string representation of the specified object.
Object
  
Returns the primitive value of the specified object.
Object
Property detail
constructorproperty
public var constructor:Object

Runtime version: AIR 1.0

A reference to the class object or constructor function for a given object instance. If an object is an instance of a class, the constructor property holds a reference to the class object. If an object is created with a constructor function, the constructor property holds a reference to the constructor function. Do not confuse a constructor function with a constructor method of a class. A constructor function is a Function object used to create objects, and is an alternative to using the class keyword for defining classes.

If you use the class keyword to define a class, the class's prototype object is assigned a property named constructor that holds a reference to the class object. An instance of the class inherits this property from the prototype object. For example, the following code creates a new class, A, and a class instance named myA:


	 dynamic class A {}

	 trace(A.prototype.constructor);      // [class A]

	 trace(A.prototype.constructor == A); // true

	 var myA:A = new A();

	 trace(myA.constructor == A);         // true

Advanced users may choose to use the function keyword instead of the class keyword to define a Function object that can be used as a template for creating objects. Such a function is called a constructor function because you can use it in conjunction with the new operator to create objects. If you use the function keyword to create a constructor function, its prototype object is assigned a property named constructor that holds a reference to the constructor function. If you then use the constructor function to create an object, the object inherits the constructor property from the constructor function's prototype object. For example, the following code creates a new constructor function, f, and an object named myF:


	 function f() {}

	 trace(f.prototype.constructor);      // function Function() {}

	 trace(f.prototype.constructor == f); // true

	 var myF = new f();

	 trace(myF.constructor == f);         // true

Note: The constructor property is writable, which means that user code can change its value with an assignment statement. Changing the value of the constructor property is not recommended, but if you write code that depends on the value of the constructor property, you should ensure that the value is not reset. The value can be changed only when the property is accessed through the prototype object (for example, className.prototype.constructor).

If you access the constructor property and compile in strict mode, you will get an error at compile time because the constructor property depends on the protoype object, which is a runtime entity. If you use standard mode or if the class description specifies "dynamic", the code runs without generating an error.

See also

prototypeproperty 
public static var prototype:Object

Language version: ActionScript 3.0
Runtime version: AIR 1.0

A reference to the prototype object of a class or function object. The prototype property is automatically created and attached to any class or function object that you create. This property is static in that it is specific to the class or function that you create. For example, if you create a class, the value of the prototype property is shared by all instances of the class and is accessible only as a class property. Instances of your class cannot directly access the prototype property.

A class's prototype object is a special instance of that class that provides a mechanism for sharing state across all instances of a class. At run time, when a property is not found on a class instance, the delegate, which is the class prototype object, is checked for that property. If the prototype object does not contain the property, the process continues with the prototype object's delegate checking in consecutively higher levels in the hierarchy until the Flash runtime finds the property.

Note: In ActionScript 3.0, prototype inheritance is not the primary mechanism for inheritance. Class inheritance, which drives the inheritance of fixed properties in class definitions, is the primary inheritance mechanism in ActionScript 3.0.

Constructor detail
Object()constructor
public function Object()

Runtime version: AIR 1.0

Creates an Object object and stores a reference to the object's constructor method in the object's constructor property.

Method detail
hasOwnProperty()method
AS3 function hasOwnProperty(name:String):Boolean

Language version: ActionScript 3.0
Runtime version: AIR 1.0

Indicates whether an object has a specified property defined. This method returns true if the target object has a property that matches the string specified by the name parameter, and false otherwise. The following types of properties cause this method to return true for objects that are instances of a class (as opposed to class objects):

The following types of properties cause this method to return false for objects that are instances of a class:

ActionScript 3.0 also has class objects, which are direct representations of class definitions. When called on class objects, the hasOwnProperty() method returns true only if a property is a static property defined on that class object. For example, if you create a subclass of Array named CustomArray, and define a static property in CustomArray named foo, a call to CustomArray.hasOwnProperty("foo") returns true. For the static property DESCENDING defined in the Array class, however, a call to CustomArray.hasOwnProperty("DESCENDING") returns false.

Note: Methods of the Object class are dynamically created on Object's prototype. To redefine this method in a subclass of Object, do not use the override keyword. For example, A subclass of Object implements function hasOwnProperty():Boolean instead of using an override of the base class.

Parameters
name:String — The property of the object.

Returns
Boolean — If the target object has the property specified by the name parameter this value is true, otherwise false.
isPrototypeOf()method 
AS3 function isPrototypeOf(theClass:Object):Boolean

Language version: ActionScript 3.0
Runtime version: AIR 1.0

Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. This method returns true if the object is in the prototype chain of the object specified by the theClass parameter. The method returns false if the target object is absent from the prototype chain of the theClass object, and also if the theClass parameter is not an object.

Note: Methods of the Object class are dynamically created on Object's prototype. To redefine this method in a subclass of Object, do not use the override keyword. For example, A subclass of Object implements function isPrototypeOf():Boolean instead of using an override of the base class.

Parameters
theClass:Object — The class to which the specified object may refer.

Returns
Boolean — If the object is in the prototype chain of the object specified by the theClass parameter this value is true, otherwise false.
propertyIsEnumerable()method 
AS3 function propertyIsEnumerable(name:String):Boolean

Language version: ActionScript 3.0
Runtime version: AIR 1.0

Indicates whether the specified property exists and is enumerable. If true, then the property exists and can be enumerated in a for..in loop. The property must exist on the target object because this method does not check the target object's prototype chain.

Properties that you create are enumerable, but built-in properties are generally not enumerable.

Note: Methods of the Object class are dynamically created on Object's prototype. To redefine this method in a subclass of Object, do not use the override keyword. For example, A subclass of Object implements function propertyIsEnumerable():Boolean instead of using an override of the base class.

Parameters
name:String — The property of the object.

Returns
Boolean — If the property specified by the name parameter is enumerable this value is true, otherwise false.
setPropertyIsEnumerable()method 
public function setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void

Language version: ActionScript 3.0
Runtime version: AIR 1.0

Sets the availability of a dynamic property for loop operations. The property must exist on the target object because this method does not check the target object's prototype chain.

Parameters
name:String — The property of the object.
 
isEnum:Boolean (default = true) — If set to false, the dynamic property does not show up in for..in loops, and the method propertyIsEnumerable() returns false.

See also

toLocaleString()method 
public function toLocaleString():String

Language version: ActionScript 3.0
Runtime version: AIR 1.0

Returns the string representation of this object, formatted according to locale-specific conventions.

The default implementation of this method does not perform locale-specific formatting and returns the same string as toString(). Subclasses should provided their own locale-aware implementation when appropriate.

Note: Methods of the Object class are dynamically created on Object's prototype. To redefine this method in a subclass of Object, do not use the override keyword. For example, a subclass of Object implements function toLocaleString():String instead of using an override of the base class.

Returns
String — A string representation of this object formatted according to local conventions.

See also

toString()method 
public function toString():String

Runtime version: AIR 1.0

Returns the string representation of the specified object.

Note: Methods of the Object class are dynamically created on Object's prototype. To redefine this method in a subclass of Object, do not use the override keyword. For example, a subclass of Object implements function toString():String instead of using an override of the base class.

Returns
String — A string representation of the object.
valueOf()method 
public function valueOf():Object

Runtime version: AIR 1.0

Returns the primitive value of the specified object. If this object does not have a primitive value, the object itself is returned.

Note: Methods of the Object class are dynamically created on Object's prototype. To redefine this method in a subclass of Object, do not use the override keyword. For example, A subclass of Object implements function valueOf():Object instead of using an override of the base class.

Returns
Object — The primitive value of this object or the object itself.

See also

Examples
examples\ObjectExample
The following example uses the classes ObjectExample and Circle to demonstrate the dynamic nature of the Object class, and how value objects can be transformed into Shape objects and then added to the stage at the specified x/y coordinates.

The example creates the value objects firstInitObj and secondInitObj. The custom class Circle accepts the value object and loops over it while setting its matching internal properties to those defined in the value object.

package {
    import flash.display.Sprite;

	public class ObjectExample extends Sprite {
		public function ObjectExample() {
			var firstInitObj:Object = new Object();
			firstInitObj.bgColor = 0xFF0000;
			firstInitObj.radius = 25;
			firstInitObj.xCenter = 25;
			firstInitObj.yCenter = 25;
						
			var firstCircle:Circle = new Circle(firstInitObj);
			addChild(firstCircle);
			firstCircle.x = 50;
			firstCircle.y = 50;

			var secondInitObj:Object = {bgColor:0xCCCCCC, radius:50, xCenter:50, yCenter:50};

			var secondCircle:Circle = new Circle(secondInitObj);			
			addChild(secondCircle);
			secondCircle.x = 100;
			secondCircle.y = 100;
		}
		
	}
}

import flash.display.Shape;
	
class Circle extends Shape {
	public var bgColor:Number = 0xFFFFFF;
	public var radius:Number = 0;
	public var xCenter:Number = 0;
	public var yCenter:Number = 0;
		
	public function Circle(initObj:Object) {
		for(var i:String in initObj) {
			this[i] = initObj[i];
		}
		draw();
	}
		
	public function draw():void {
		graphics.beginFill(bgColor);
		graphics.drawCircle(xCenter, yCenter, radius);
		graphics.endFill();
	}
}