Answered
Best way to insert data in custom class instances
Hi.
I have created a custom class (mySuperClass) in an .as file, defined the constructor, properties and get/set methods. Now in the main .fla I have to declare a large number of instances of that class and fill in each property. The "correct" method, I guess, would be to:
var super1:mySuperClass = new SuperClass();
super1.setProperty1 ( value1_1);
super1.setProperty2 ( value1_2);
...
super1.setPropertyN ( value1_N);
...
var superM:mySuperClass = new SuperClass();
superM.setProperty1 ( valueM_1);
...
superM.setProperty1 ( valueM_N);
However, with large amounts of variables and information that share the same basic characteristics, I always feel tempted to get it done by way of a for... cycle. In this case I'd probably build arrays with the properties to be filled in.
So what I would like to know is how would you guys do this? Are there other ways to do this?
Thanks in advance.
I have created a custom class (mySuperClass) in an .as file, defined the constructor, properties and get/set methods. Now in the main .fla I have to declare a large number of instances of that class and fill in each property. The "correct" method, I guess, would be to:
var super1:mySuperClass = new SuperClass();
super1.setProperty1 ( value1_1);
super1.setProperty2 ( value1_2);
...
super1.setPropertyN ( value1_N);
...
var superM:mySuperClass = new SuperClass();
superM.setProperty1 ( valueM_1);
...
superM.setProperty1 ( valueM_N);
However, with large amounts of variables and information that share the same basic characteristics, I always feel tempted to get it done by way of a for... cycle. In this case I'd probably build arrays with the properties to be filled in.
So what I would like to know is how would you guys do this? Are there other ways to do this?
Thanks in advance.