1

I've recently started using AS3, and I've ran into a little problem.

I want to store some functions into an array like so:

testArray:Array = [testfunction(), testfunction2()];

But when I start it up, all the functions will fire off without being called. Is there a way to prevent this? Thanks in advance.

1 Answer 1

8

() is used to call a function, you just need to store a reference to the function. Your code calls the functions and stores their results in the array or undefined if the functions don't return anything. Try :

var testArray:Array = [testfunction, testfunction2];

To call the first function :

testArray[0]();

or :

var func:Function = testArray[0];
func();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.