views:

22

answers:

1

I want to create a function pointer object:

private var func:Object = { Class.Constant: function };

What is the clean way of doing this? I did the above and got

Error: Syntax error: expecting colon before dot.

And I'm not even sure that's right. The goal is that I can just do

func[ Constants ]();

somewhere later.

+1  A: 

Try this:

private var func:Object = { };
func[ Class.CONSTANT ] = function() { };

If you want to do it at definition:

private const KEY:String = Class.CONSTANT;
private var func:Object = { KEY: function() { } };
Brian McKenna
So there's no doing it in one go?
Timmy
I just added a definition example.
Brian McKenna