[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

Flash Array of custom classes

How do I make this work?

import package.myClass;

var arrayOfMyClass:Array;

arrayofMyClass= new Array;

arrayofMyClass[0]=new myClass;
arrayofMyClass[1]=new myClass;
arrayofMyClass[2]=new myClass;
arrayofMyClass[3]=new myClass;

Clearly I want an Array, but I want each element of the array to be an instance of my custom class.

Thanks
0
dban00b
Asked:
dban00b
  • 2
1 Solution
 
najhCommented:
well from first glance you've called new on your myClass class but you haven't called it properly - with a ()

so it'd be more like

new myClass();

but i've never done what you're doing before so other than that suggestion I can't comment.
0
 
najhCommented:
oh and same goes for the array - the new operator will expect a () after the class

so arrayofMyClass= new Array();

This might seem strange, but you're actually calling the constructor method. Method calls take arguments in brackets, and if there aren't any arguments, you leave the brackets empty.
0
 
dban00bAuthor Commented:
whoops.  Oh well. thanks for the easy fix.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now