For more information on the Application class, see the
Server-Side ActionScript Language Reference.
Using the application.onConnect handler
The
application.onConnect
NetConnection.connect()
passed a reference to a server-side Client object, representing the client that's attempting to
connect, as well as any developer-defined parameters passed to the
NetConnection.onConnect
Setting up methods in a function assigned to the
approach when you want to set up different methods based on user login information.
However, if you want to set up a method that is available to all clients, you can use the
ActionScript 1.0
prototype
// A user has connected
application.onConnect = function(newClient, userName)
{
if (userName == "admin")
{
newClient.adminFunc= function(param)
{
// some code that's only useful to the admin
newClient.myAdminProperty = param;
}
} else
{
// code for most cases
}
// Allow the logon
application.acceptConnection(newClient);
}
// this part could be in a separate file
// Every client (including admin) is going to have this function
// (because of the way "prototype" works).
Client.prototype.commonFunction = function (myColor)
{
// some code
// use this to refer to the client instead of newClient
this.color = myColor;
}
event handler is invoked on the server when a client calls the
method. The handler
handler.
application.onConnect
property of the Client object, as in the following example:
Application class
handler is automatically
onConnect
About the Application class
entry in the
handler is a good
43
Need help?
Do you have a question about the FLASH MEDIA SERVER 2-DEVELOPING MEDIA and is the answer not in the manual?
Questions and answers