ActionScript Flash Remoting Web Services

Updated Class Browser with hidden classes

The “class browser” has been updated – it now includes hidden class files for data connectivity.

Unless you add these hidden files to the actual paths, you’ll see a little yellow triangle (see diagram) and won’t be able to double-click and see the class definitions. However, they’re still useful as a quick lookup of the class paths for entering into your code.

Note that the Include folder contains files that are part of Flash Remoting Components for Flash MX 2004.

For non-English installations, you may have to change the class paths in this .flp file. Open it up in a text editor, Find & Replace words like “/Program Files/” and “/en/” to your OS settings.

You can download the updated file here.

ActionScript ColdFusion

Generate project files automatically

Chris Kief of Rise Interactive released a Flash Project file generator that automatically creates something like the class browser. It requires ColdFusion 6+ to parse directories.

Get it from here.


Cross domain policy file

These two important documents provide better understanding of the new Flash Player 7 security changes, and what to do about it:

Security Changes in Macromedia Flash Player 7

External data not accessible outside a Macromedia Flash movie’s domain

ActionScript OOP

Inheritance in ActionScript 2.0

Back in the good old days of Flash 5 and MX, trying to do inheritance in ActionScript required some knowledge of what goes on behind the scene. Also, the infamous superclass invocation bug haunted developers for almost three years.

Now in ActionScript 2.0, with the new OOP-specific keywords, inheritance is much simpler:

class Parent {


class Child extends Parent {


That’s all. And the keyword “super()” in the Child class constructor is not even mandatory because the compiler inserts it for you!

As for the superclass invocation bug, it is now fix for Flash player 7!


Code hints

In Flash MX 2004, some of the component code hints are not listed in AsCodeHints.xml or UIComponents.xml. As a result, what used to be a common thing to do in MX by using code hints such as _cb for ComboBox, does not work now.

Well, there are two solutions:

1) Add you own code hints information to the two files mentioned above.

2) Reference the component class in your code:

var sp:mx.containers.ScrollPane;

Now when you type sp. the list of ScrollPane methods and property is displayed!

Thanks go to Rebecca Sun of Macromedia for this tip.


ActionScript 2.0

Here are some of the new features in ActionScript 2.0, and why one would want to use it instead of ActionScript 1.0 (yes, you can still use the older syntax in Flash MX 2004).

ActionScript 2.0 is not a new language. It is an enhancement to the previous version, by building on the existing language. In fact, Flash MX 2004 compiles AS2 into AS1 equivalent bytecodes. One reason for this is backwards compatibility in Flash Player 6. As a result, one can code in AS2 and compile it for Flash Player 6. For better optimization, target for Flash Player or higher. Some version 2 components won’t run except in FP7, but some can run in as well.

In terms of building applications, ActionScript 1.0 (and ECMAScript 3 in general) requires getting intimate with something called the prototype (and __proto__ if you’re a rebel trying to avoid unwanted side effects). The reason being that there was no ‘class’ construct, and inheritance was done in a very odd way.

Now in ActionScript 2.0, it is more suitable for OOP because of the following new keywords and features:

class, interface, extends, implements, private, public, dynamic, instrinsic, static, get, set, import; class path (similar to package), and strict data typing (useful in locating problems at compile time).

With these new features in ActionScript 2.0, building robust applications is becoming more attractive, and in a way easier. However, because Flash MX 2004 does not care if AS1 or AS2 is used (in most cases), one can still continue using AS1 and slowly migrate over to AS2.

ActionScript OOP Tips & Tricks

abstract class

Since ActionScript 2.0 does not have the “abstract” modifier, here’s one way to create a class that acts like an abstract class, by making the constructor private:

class PretendToBeAbstractClass {
    // private constructor
    private function PretendToBeAbstractClass() {}

When the following statement is compiled, the compiler will complain that one can’t instantiate from this class because the constructor is private:

var o:PretendToBeAbstractClass = new PretendToBeAbstractClass();

Although the constructor is private, but because it behaves as protected, you can still extend this class:

class MyClass extends PretendToBeAbstractClass {

What is missing is the compiler does not actually know what an abstract class is; therefore there won’t be any warning messages.

As I mentioned in the last post, you can get around all the type-checking at runtime, and even instantiating an “abstract” class at runtime like this:

var o = new _global["PretendToBeAbstractClass"]();

Or even access “private” properties from it:


Obviously these actions defeat the purpose of strict-typing, but it is possible (until runtime type-checking is implemented).

ActionScript Design Patterns OOP Tips & Tricks


Here’s one way to implement a Singleton in ActionScript 2.0:

class Singleton {
	// the only instance of this class
	private static var inst:Singleton;

	// keep count of the number of Singleton objects referenced
	private static var refCount:Number = 0;

	// constructor is private
	private function Singleton() {}

	// get an instance of the class
	public static function get instance():Singleton {
		if (inst == null) inst = new Singleton();
			return inst;

		// return the number of instance references
		public static function get referenceCount():Number {
		return refCount;

The count property is for keeping count of the number of Singleton objects referenced (obviously it is not aware of destroyed objects), and is not really a necessary member of the Singleton pattern.

To use this class, one would write something like this:

var s1:Singleton = Singleton.instance;
var s2:Singleton = Singleton.instance;

Now s1 and s2 are the same instance of the Singleton class.

ActionScript OOP

private, protected & public

In ActionScript 2.0, there are “private” and “public” modifiers, but there is no “protected”. However, “private” behaves like “protected” – i.e. subclasses and instances can access private members; so there is no true private scope.

To make sure the compiler catches access to private properties/functions, strict-typing has to be used:

class SomeClass {
     private var:somePrivateProperty:String;

// without specifying the type of the instance, the compiler will not
// prevent statements from accessing private properties; therefore,
// o.somePrivateProperty is accessible

var o = new SomeClass();

// by specifying the type, the compiler will catch acess to
// private members:
var o:SomeClass = new SomeClass();

Because type-checking is only performed at compile time, there is no guarantee that private members cannot be accessed at runtime.

By default, if the “public” modifier is left out, the member is assumed to be public.