Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe Flash

Server-Side ActionScript (SSAS)

  • Print
  • + Share This
This sample chapter will step you through the objects available to you with SSAS including SharedObject, Stream, Application, Client, and NetConnection. You will review some SSAS that you can use for a simple authentication system using an ActionScript array. The chapter will also handle techniques you can use to help debug SSAS.

Server-side ActionScript (SSAS) is just like Macromedia Flash ActionScript except it exists on the server. Just as Flash ActionScript is based on the ECMAScript-262 specification, SSAS also uses the standard as a foundation. SSAS closely follows the implementation of Server-Side JavaScript 1.5 (SSJS) used by the SunONE Server and the Netscape Enterprise Server. You will find it interesting to review more about SSJS presented in Netscape's Developer pages (http://developer.netscape.com). SSAS does not include the SSJS LiveWire objects used for direct database access, nor does it include the object to connect to email server and the file system. This was done to ensure SSAS's security model was tight. SSAS cannot access the file system or database server directly. SSAS can handle databases and external servers through Flash Remoting MX and compatible application servers. Flash Remoting MX will be discussed in detail in Chapter 13, "Accessing External Data."

SSAS cannot directly control Flash elements such as MovieClips, buttons, or objects with this script. However, it can invoke methods within the Flash movie that can alter the elements of the movie. SSAS acts like a facilitator between multiple Flash movies and other servers. SSAS is the communication hub. You can build objects to store data, or methods to handle communication events.

There are two important things you should remember before you start working with SSAS:

  • Any change made to SSAS in ASC files requires a reload of the application.

  • SSAS is CaSe seNSitiVe, unlike its Flash MX counterpart. For example, the following two variable definitions would create two different variables:

    var myVariable = 123;
    var MYVARIABLE = 456;

This chapter will step you through the objects available to you with SSAS including SharedObject, Stream, Application, Client, and NetConnection. You will review some SSAS that you can use for a simple authentication system using an ActionScript array. The chapter will also handle techniques you can use to help debug SSAS. Each object's methods, properties, events, and information objects are presented in the Quick Reference appendices in the back of this book.

The main.asc File

The main.asc file is the heart of your application. You have used it already in previous chapters as a place for server-side ActionScript. Macromedia Flash Communication Server always looks for the main.asc file when it is loaded the first time. If the main.asc file is not available, Flash Communication Server looks for a file with the name of the application. For example, Communication Server would look for a file called myApp.asc within an application called myApp. main.asc is always loaded first, if it exists. All SSAS must stem from either of these files. The server looks first for main.asc, and then it looks for myApp.asc. If both files exist, main.asc takes priority, and myApp.asc is ignored. This does not mean that all SSAS must exist solely in the file. You can "include" external scripts inline. You saw this in earlier exercises when the components.asc file was loaded. This particular load reference includes the server-side counterparts for the Flash UI components that are nothing more than SSAS object classes.

The process of including scripts is handled by the load method. This method loads any ASC files relatively located to the main.asc or application-named file. Loaded scripts are inserted inline just like server-side includes, or a <CFINCLUDE> for those Macromedia ColdFusion buffs out there. They are compiled after being loaded with scripts inside the main.asc file. Their libraries are made available to the Application instances.

SSAS is compiled into the application each time it is instantiated. When a change is made to server-side files (ASC files), those changes do not take effect in an Application instance until it is reloaded. This can get tricky if you have multiple instances running. It is possible to have multiple versions of the application running, if you do not reload each instance. There are three ways to reload your application: through the Communication App Inspector, the Administration Console, or by using the ActionScript API.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.