View comments | RSS feed

Using server-side ActionScript

To use server-side ActionScript with a Flash Media Server application, you write the code, add the script file to the appropriate server directory, and run the SWF file that connects to the server. To understand the architecture of Flash Media Server and its applications, see Developing Media Applications.

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.

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.

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.

    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.

  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.
  4. Place the main.asc file in the appName directory or in a subdirectory called scripts in the appName directory.
  5. Open the Flash application (the SWF file) in a browser or in the stand-alone Flash Player.

    The SWF file must contain ActionScript code that passes appName to the connect method of the NetConnection class, as shown in the following example:

    nc = new NetConnection();
    nc.connect("rtmp://flashcomsvr.mydomain.com/myFlashComAppName");
    

    NOTE

     

    You can use the management console to check if the application loaded successfully.


Comments


No screen name said on Aug 31, 2006 at 12:19 PM :
It would be very useful if references to other documents would be hyperlinked. For example: "Developing Media Applications" in the first paragraph.

Here is a link to the entire "Flash Media Server Documentation" page. "Developing Media Applications" is the second section on this page, from which the PDF can be downloaded or viewed in the browser: http://www.adobe.com/support/documentation/en/flashmediaserver/

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000631.html