Posts Tagged class

Constructor Function

Tags: ,

It’s very nice in AS3 to simply state the name of a function and get a Function variable back, regardless of whether or not it is a method, static method, dynamic function, or plain function in a package. Most other languages do not allow this level of convenience. Java doesn’t allow it at all and C++ and AS2 require fanciness in order to pass the this pointer. However, when you want a Function for the constructor of a class, you get a Class variable back. This article will show you a way to get a Function variable that will create an instance of a class when called.

Read the rest of this article »

8 Comments

Weak References

Tags: , , ,

Weak key support in the Dictionary class is one of those rarely-used features that can be greatly useful on occasion. This is the only place in the Flash API where weak references are used. In Java, there is another useful class for when you just want to make one weak reference, not a whole table of them: the aptly-named WeakReference class. Below is my own implementation, which is both simple and useful.

Read the rest of this article »

4 Comments

Runnables as Function Pointers

Tags: , , ,

Last Friday’s article expressed some longing for C-style function pointers. It attempted to use AS3’s Namespace class to fake a function pointer. Unfortunately, this resulted in far slower code than simple direct access. Today’s article shows a technique that actually results in far faster code!

Read the rest of this article »

16 Comments

Dynamic Access Part 2: Dynamic Classes and Plain Objects

Tags: , , ,

Welcome to the second part of this series on dynamic access. Last time we covered indexing arrays and vectors. This time we’ll talk about dynamic classes and plain objects. These are definitely something to watch out for when writing performance-critical code.

Read the rest of this article »

No Comments

Class Bootup

Tags: , ,

Being allowed to declare and define member variables all at once introduces a question: in which order does the class boot up? Further, if the class has parent classes, how does this change things? Read on for the simple results.

Read the rest of this article »

2 Comments

Overriding Variables

Tags: , ,

AS3 makes some strange things possible. Even stranger, it seems to do this without any warning by its compiler: MXMLC. It seems as though one of these strange things is the ability to override the variables of your parent classes.

Read the rest of this article »

3 Comments

Abstract Classes

Tags: ,

Abstract classes are an explicit language feature of Java via the abstract keyword. In C++ they are less explicit via pure virtual functions. In AS3 they are only enforceable at runtime. There are many ways to go about creating abstract classes. This article shows you some of the ways.

Read the rest of this article »

2 Comments

Uses for arguments

Tags:

The arguments magic variable has been around since the AS2 days. It used to be more useful than it is in AS3, but don’t overlook it completely!

Read the rest of this article »

2 Comments