I'm new at using classes in ActionScript. Basically what I'm trying to do is create an array of objects using a Constructor and attendant methods. I'm using trace to try and return position properties so that I know whether what I am doing is working. Obviously, it is not working, because it is returning "undefined" for each value. Other than that, I'm not getting any errors, and I can't find the glitch.
The file is attached.
Last edited by The Public; 11-19-2003 at 04:01 AM.
I renamed your class from "Module" to "myModule" (thinking there may be a reserved word, maybe not...)
You need to call methods by using the classname first, in your loop:
myModule[i].getPos(0);
myModule[i].getPos(1);
And, you had functions returning 'this.xPosition' which is where you were getting your 'undefined' variables. Flash didn't know that variable existed. I changed it to 'return this._x' and voila!
There's traced statements in there to show you the result.
Also, as it stands, you'll need to add more code to set your colors... (create a color object)
For some reason, I can't open the file that you reposted. FlashMX says "Unexpected File Format Encountered." Could you maybe post the code directly to the forum. I tried making the changes to my file based on what you described, but it doesn't work.
Thanks again.
Joshua
Last edited by The Public; 11-19-2003 at 11:03 PM.
Yes, that works. I'm not sure why the corrections that I made didn't work, because I did the same thing. I must have had a small hidden error somewhere.