Posts Tagged functions

Callback Strategies

I’ve previously covered ways of implementing in my article on Runnables (aka observers) which showed how to call back about 15 times faster than just using a Function object. There are still more ways to call back though and I didn’t cover them at the time. Today I’ll be adding to Function and Runnables by testing Event and the as3signals library by Robert Penner.

Read the rest of this entry »

Tags: , , , , ,

14 Comments

Miscellaneous Utility Functions

The last three articles have been about utility functions for objects, classes, and display objects. This is the finale in the series and contains some leftover utility functions.

Read the rest of this entry »

Tags: , , ,

3 Comments

Utility Functions For DisplayObjects

Hot on the heels of my articles about utility functions for objects and classes, today’s article has a set of utility functions for DisplayObjects.

Read the rest of this entry »

Tags: ,

9 Comments

Utility Functions For Classes

On the heels of last Friday’s article on Utility Functions For Objects, today’s article will show a few utility functions for the Class class. In case you’re not familiar with it, Class represents a class like you would write and is useful main for more dynamic programming where you want to instantiate a class based on a variable (eg. var c:Class) rather than a constant (eg. BitmapData). So how do you get a Class variable? The Flash API provides some ways to go about it and I’ll provide some ways to make that more convenient.

Read the rest of this entry »

Tags: ,

8 Comments

Utility Functions For Objects

Like most programmers writing non-trivial applications, I’ve piled up a lot of utility functions over the years. Most of them are simple and effective. They are short and get their job done. You or someone you know has probably written these functions, but maybe not in AS3. So today I’m going to share a few utility functions for Objects in AS3.

Read the rest of this entry »

Tags: ,

11 Comments

Inlining Math Functions

As a followup to my article on Inlining Math.ceil(), I decided to inline some more functions in the Math class. Read on for the code as well as tests proving correctness and speed.

Read the rest of this entry »

Tags: , , , ,

3 Comments

Beware of Getters and Setters

Getters and setters are indeed a very nice feature of AS3. They eliminate a lot of typing (.x versus .getX()) shaves off five characters and removes the need to hit the shift key for X) and make getting and setting values much more natural by disguising the fact that you’re actually calling a function. The downsides include the difficulty (impossibility?) of getting a Function variable for them and lower performance. This article is about that performance hit. EDIT: added a plain getter test)

Read the rest of this entry »

Tags: , , ,

7 Comments

Function Performance

With access specifiers, statics, plain functions, and overriding, there are a lot of ways you can dress up a function in AS3. But how many programmers really know the performance implications of these options? Read on to find a straightforward test showing just that. EDIT: added functions defined in interfaces, getters, setters, and final functions.

Read the rest of this entry »

Tags: , , , , , , , , ,

25 Comments

Reverse Currying

As a followup to last week’s article on curry functions, today’s is about the reverse of currying.

Read the rest of this entry »

Tags: , ,

2 Comments

RegExp In An Anonymous Function

Regular expressions are downright handy for a variety of string processing tasks. They are so handy that they are built straight in to the language in the form of the /regexpgoeshere/ syntax. Well, usually…

Read the rest of this entry »

Tags: ,

6 Comments