richjamison
02-25-2008, 04:23 PM
I have a MovieClip "tableCell_mc" that is added to the stage via AS3. This MovieClip has a few variables that I have declared within it. These variables are as follows:
var tableCellHomeX:int;
var tableCellHomeY:int;
var myChildren:Array = new Array();
stop();
I use these to store unique data to each instance of tableCell_mc.
I can access the tableCellHomeX and tableCellHomeY vars no problem. It's the myChildren:Array that I'm having trouble with. It's an empty array but as I go through my for loop I try to add values to that array like so.
function makeTable(theXMLList:XMLList) {
var theXMLListAttribs:XMLList = theXMLList[0].attributes();
for (var i:int = 0; i < theXMLListAttribs.length(); i++) {
tableHeader = new tableCell_mc();
tableHeader.width = stage.stageWidth / theXMLListAttribs.length();
tableHeader.x = 0;
tableHeader.y = 100;
tableHeader.tableCellHomeX = tableHeader.width * i;
tableHeader.tableCellHomeY = 100;
tableHeader.cellValue_text.text = theXMLListAttribs[i].name();
tableHeader.addEventListener(Event.ADDED_TO_STAGE, slideToRight);
tableHeader.addEventListener(TweenEvent.MOTION_FIN ISH, dummyFunction);
addChild(tableHeader);
for (var j:int = 0; j < theXMLList.length(); j++) {
var myAttribs:XMLList = theXMLList[j].attributes();
tableHeader.myChildren[j] = String(myAttribs[i]);
}
}
}
I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SpreadSheet_fla::MainTimeline/makeTable()
at SpreadSheet_fla::MainTimeline/frame2()
Help anyone?
Thanks,
Rich
var tableCellHomeX:int;
var tableCellHomeY:int;
var myChildren:Array = new Array();
stop();
I use these to store unique data to each instance of tableCell_mc.
I can access the tableCellHomeX and tableCellHomeY vars no problem. It's the myChildren:Array that I'm having trouble with. It's an empty array but as I go through my for loop I try to add values to that array like so.
function makeTable(theXMLList:XMLList) {
var theXMLListAttribs:XMLList = theXMLList[0].attributes();
for (var i:int = 0; i < theXMLListAttribs.length(); i++) {
tableHeader = new tableCell_mc();
tableHeader.width = stage.stageWidth / theXMLListAttribs.length();
tableHeader.x = 0;
tableHeader.y = 100;
tableHeader.tableCellHomeX = tableHeader.width * i;
tableHeader.tableCellHomeY = 100;
tableHeader.cellValue_text.text = theXMLListAttribs[i].name();
tableHeader.addEventListener(Event.ADDED_TO_STAGE, slideToRight);
tableHeader.addEventListener(TweenEvent.MOTION_FIN ISH, dummyFunction);
addChild(tableHeader);
for (var j:int = 0; j < theXMLList.length(); j++) {
var myAttribs:XMLList = theXMLList[j].attributes();
tableHeader.myChildren[j] = String(myAttribs[i]);
}
}
}
I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SpreadSheet_fla::MainTimeline/makeTable()
at SpreadSheet_fla::MainTimeline/frame2()
Help anyone?
Thanks,
Rich