Using Multiple Script Files - MACROMEDIA FLASH MEDIA SERVER 2-DEVELOPING MEDIA Develop Manual

Developing media applications
Table of Contents

Advertisement

In contrast, suppose you use the
server side:
// This is client-side ActionScript in the FLA file.
NetConnection.call("someServerMethod");
// This is server-side ActionScript in the main.asc file.
client.prototype.someServerMethod = function(){
// code here
}
// The following code would also work.
application.onConnect = function(newClient) {
newClient.someServerMethod = function(){
// code
}
return true;
}
In this case, the parameter passed to
side Client object that was previously defined in the main.asc file. This is because any method
in the server code that the client can call must be a property of a server-side Client object.

Using multiple script files

As your application increases in complexity, don't try to use a single script to do everything:
break your functionality up into multiple scripts, each of which provides a specific set of
functionality. If you do use more than one file, you can use a "once-only inclusion" definition
to optimize performance and to prevent a file from being evaluated more than once.
For example, on the client side, to make a file named my_file.as available to other files in your
application, include the following code in my_file.as:
if (_root._my_file_as == null) {
_root._my_file_as = true;
// All the code for myfile.as goes here
}
In your other files, issue the following command:
#include "my_file.as";
The
happens at the time code is compiled, not at runtime.
#include
method from the client, to call a method on the
call()
NetConnection.call()
must be a method of the server-
Using multiple script files
85

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MEDIA SERVER 2-DEVELOPING MEDIA and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash media server 2

Table of Contents