setAttributes(object, propName, enumerable, readonly, permanent)
Prevents certain methods and properties from being enumerated, writable, and deletable. In a server-side script, all properties in an object are enumerable, writable, and deletable by default. Call setAttributes() to change the default attributes of a property or to define constants.
Flash Media Server 2
object An Object.
propName A string indicating the name of the property in the object parameter. Setting attributes on nonexistent properties has no effect.
enumerable One of the following values: true, false, or null. Makes a property enumerable if true or nonenumerable if false; a null value leaves this attribute unchanged. Nonenumerable properties are hidden from enumerations (for var i in obj).
readonly One of the following values: true, false, or null. Makes a property read-only if true or writable if false; a null value leaves this attribute unchanged. Any attempt to assign a new value is ignored. Typically, you assign a value to a property while the property is writable and then make the property read-only.
permanent One of the following values: true, false, or null. Makes a property permanent (nondeletable) if true or deletable if false; a null value leaves this attribute unchanged. Any attempt to delete a permanent property (by calling delete obj.prop) is ignored.
The following code prevents the resolve() method from appearing in enumerations:
Object.prototype.__resolve = function(methodName){ ... };
setAttributes(Object.prototype, "__resolve", false, null, null);
The following example creates three constants on a Constants object and makes them permanent and read-only:
Constants.KILO = 1000; setAttributes(Constants, "KILO", null, true, true); Constants.MEGA = 1000*Constants.KILO; setAttributes(Constants, "MEGA", null, true, true); Constants.GIGA = 1000*Constants.MEGA; setAttributes(Constants, "GIGA", null, true, true);