User Guide

6 Server-Side ActionScript Language Reference
Create the server-side ActionScript file and name it main.asc. All ActionScript code that is
embedded in the script file and not in a function body executes once when the application is
loaded but before the
application.onAppStart event handler is called.
To install and test the server-side ActionScript file:
1. Locate the Macromedia Flash Media Server /applications directory.
The default location of the /applications directory is in the Macromedia Flash Media
Server product installation directory.
2. Your server-side script file must be named main.asc, main.js, registered_app_name.asc, or
registered_app_name.js.
3. Create a subdirectory in the /applications directory called appName, where appName is a
name you choose as the filename of your Flash Media Server application. You must pass
this name as a parameter to the
NetConnection.connect() method in the client-side
ActionScript.
NOTE
You can name your server-side ActionScript file app_name, where app_name is the
name of your application’s directory, and save it with a file extension of .asc or .js. Also,
any double-byte characters (including characters of all Asian languages) in the server-
side ActionScript file must be UTF-8-encoded. For more information on server-side
script files, see
Developing Media Applications
.
NOTE
For large-scale applications, you may need to use multiple server-side script files. You
can use the Flash Media Server archive compiler utility to deploy those files as a
package from a single location. For more information, see “
Archiving and compiling
server-side script files
” in
Developing Media Applications
.
NOTE
Server-side scripts also have a secure loading phase, during which critical code can be
loaded before the main application loading phase. Server-side scripts also let you create
protected objects
; these are objects whose methods and data cannot be inspected or
manipulated. These two features allow you to implement
system calls
that protect critical
data and functions. For more information, see
“Implementing secure system objects”
in
Developing Media Applications
.
NOTE
If you did not accept the default installation settings and you aren’t sure where the
/application directory is located, the location is specified in the
AppsDir tag of the
Vhost.xml file, which is located at /Flash Media Server /conf/defaultRoot/
defaultVhost. For information about configuring a different application directory, see
Managing Flash Media Server. Although your SWF and HTML files should be
published under a web server directory, your server-side ASC files, your audio/video
FLV files, and your ActionScript FLA source files should not be accessible to a user
browsing your website.