PDA

View Full Version : class variables declaration


ozhanlion
04-07-2007, 10:17 PM
can someone tell me if I am doing something wrong with the initial declarations and all that stuff? It keeps showing me error but it doesn't say what it is. I am developing on flex builder 2.
also I am wondering, aren't we supposed to initialize array as fields? so if I declare it in the constructor, is it still valid for throughout the class?


ty
oz


package
{
public class ArraySystem {
public var numParticles;
public function ArraySystem() {
ptCount = 0;
numParticles = 20;

var PRTS = new Array(numParticles);
for (var i:int = 0; < this.numParticles; i++) {
PRTS[i] = new Circle();
}
}

public function draw():void {
for (var i:int = 0; < this.numParticles; i++) {
PRTS[i].getTrace();
}
}
}
}

ozhanlion
04-07-2007, 11:19 PM
wow, I am blind :)

ok so for the sake of the thread, my question is still valid. Can we get away by initializing our arrays in the constructor and still include the scope of the class?

senocular
04-08-2007, 02:32 PM
you can initialize arrays in your class body or your constructor (and really, anywhere as soon as it happens before some other action runs that expects it to be done)