Archive for July 9th, 2004

09
Jul

Working with strongly typed variables and LocalConnection in ActionScript 2

Oddly the LocalConnection class is not defined as dynamic in the ActionScript 2 intrinsic classes, even though the documentation demonstrates dynamic usage as an example of the LocalConnection class.

However, the fact that it is not declared dynamic can be turned into a positive thing and force us to use good OOP practices instead. Normally when we use LocalConnection we create an instance and then assign a function on that instance. This method of declaring functions should be avoided in AS2 as it violates several core concepts in object oriented programing.

The better way to implement LocalConnection is to create a class that extends LocalConnection and adds the functions you need in your application. That way you can strongly type the instances to your extended LocalConnection class and still benefit from all the advantages of AS2.

Here’s an example of a LocalConnection subclass we used in a recent application.

Continue reading ‘Working with strongly typed variables and LocalConnection in ActionScript 2′