0

In Java it is possible to set the datatype of an array, and by setting the datatype to the object I am using, I can call the methods and variables of that object. For instance:

ArrayList<Object> name = new ArrayList<Object>();
name.add(new Object(variables));
name.get(0).method;

Is there any way I can do this in ActionScript?

1 Answer 1

2

A Vector will let you easily call the functions of your objects which are stored in that vector.

var vector:Vector.<YourObject> = new Vector.<YourObject>();
vector[0].yourObjectFunction();

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html

Alternatively, you can cast the members of an Array to a specific type and then call the functions.

(array[0] as YourObject).yourObjectFunction();
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.