
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
4
// so that it is read-only and not deletable.
global["system"] = protectObject(sysobj);
setAttributes(global, "system", false, true, true);
// Now add a global load() function for compatibility.
// Make it read-only and nondeletable.
global["load"] = function(path){
return system.load(path);
}
setAttributes(global, "load", false, true, true);
See also
LoadVars class
setAttributes()
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.
Availability
Flash Media Server 2
Parameters
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 nonenu-
merable if
false; a null value leaves this attribute unchanged. Nonenumerable properties are hidden from enumer-
ations (
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.
Example
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;
Commentaires sur ces manuels