This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Chapter 4: Applications, Instances, and Server-Side ActionScript
// The user variable holds an instance of the User class
user = new User( );
In Flash 5 and Flash MX, this would essentially disable the constructor, but in SSAS,
the difference in capitalization means that User (the class) and
user (a variable hold-
ing an instance of the class) are different entities. A common practice to avoid confu-
sion is to append the word “Class” onto the constructor function name:
function UserClass ( ) {
user = new UserClass( );
Working with Inheritance
Server-Side ActionScript does not support the formal definition of classes and inter-
faces supported by client-side ActionScript 2.0. SSAS supports prototype-based
inheritance but is a little different from Flash ActionScript 1.0. Flash MX added the
super operator to client-side ActionScript to make it easy to call the constructor func-
tion and methods of a superclass. Although super is not part of the ECMAScript ver-
sion 3 language defined in ECMA-262, it is proposed for a future version of the
standard. The super operator is not available in SSAS. However you can permit a
subclass to access the constructor and methods of a superclass in a number of ways
in SSAS. Example 4-1 shows one way to call the constructor and methods of a super-
class in SSAS.
Example 4-1. Calling the constructor and methods of a superclass in SSAS
SuperClass = function (a) {
this.a = a;
SuperClass.prototype.method = function ( ) {
trace("SuperClass method called. a is: " + this.a);
SubClass = function (a, b) {
SuperClass.apply(this, arguments);
this.b = b;
SubClass.prototype = new SuperClass( );
SubClass.constructor = SubClass;
SubClass.prototype.method = function ( ) {
trace("In Subclass method. a and b: " + this.a + ", " + this.b);
SuperClass.prototype.method.apply(this, arguments);
subClass = new SubClass(1, 2);
subClass.method( );

Get Programming Flash Communication Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.