The previous example works, but must be executed every time a client connects. If you want
the same methods and properties to be available to all clients in the
array without defining them every time, you must assign them to the
the Client class. There are two steps to extending a built-in class using the
method. You can write the steps in any order in your script. The following example extends
the built-in Client class, so the first step is to write the function that you will assign to the
property:
prototype
// First step: write the functions.
function Client_getWritePermission(){
// The writeAccess property is already built in to the client class.
return this.writeAccess;
}
function Client_createUniqueID(){
var ipStr = this.ip;
// The ip property is already built in to the client class.
var uniqueID = "re123mn"
// You would need to write code in the above line
// that creates a unique ID for each client instance.
return uniqueID;
}
// Second step: assign prototype methods to the functions.
Client.prototype.getWritePermission = Client_getWritePermission;
Client.prototype.createUniqueID = Client_createUniqueID;
// A good naming convention is to start all class method
// names with the name of the class followed by an underscore.
You can also add properties to
Client.prototype.company = "Macromedia";
The methods are available to any instance, so within
passed a
argument, you can write the following code:
clientObj
application.onConnect = function(clientObj){
var clientID = clientObj.createUniqueID();
var clientWritePerm = clientObj.getWritePermission();
};
48
Server-Side ActionScript Language Reference
, as shown in the following example:
prototype
application.clients
prototype
application.onConnect
property of
prototype
, which is
Need help?
Do you have a question about the FLASH MEDIA SERVER 2-SERVER-SIDE ACTIONSCRIPT LANGUAGE and is the answer not in the manual?