I have a class in which I have declared an array. The functions in that class are designed to make changes to the array, but it’s not working:
package {
import flash.net.*;
import flash.xml.*;
import flash.events.*;
public class Checklogic extends EventDispatcher {
private var customerCheck:Array = new Array();
public function resetCheck():void {
trace("called reset check");
// clear all chars on check
for(var i:int=0; i<customerCheck.length; i++) {
customerCheck.pop();
}
trace(customerCheck);
}
public function getNumberOfCheckItems() {
return customerCheck.length;
}
public function getCustomerCheckArray() {
return customerCheck;
}
public function addCharToCheck(sentObject) {
trace("Sent Object: "+sentObject.body);
trace("before push: ");
trace(customerCheck);
customerCheck.push(sentObject);
trace("after push: ");
trace(customerCheck);
}
}
}
Anything I do to customerCheck treats it as if it were a new array. This is especially obvious when using customerCheck.push in addCharToCheck() – the trace always shows a blank array before push and an array with one object in it after the push… then next time it does the same.
I know I’m making some sort of fundamental error regarding the scope of the array within the class but I just cannot find any good information on how to fix it!
Any help is greatly appreciated. Moving to AS3 (been coding it for all of about 3 weeks) is a nightmare so far, and it seems to be the ‘easy’ stuff that causes me problems