I have four classes: document, topPanel, listPanel and detailsPanel. In this particular example the topPanel checks when to advanceDay (a function in document). When advanceDay is activated document tells topPanel to calculateDate, listPanel to sortList and detailsPanel to refreshDetails. calculateDate then works out the date and tries to update a dynamic text field but can’t find it’s instance. Similar problems occur in regards to sortList and refreshDetails.
topPanel:
function advanceLoop(a:Event)
{
loopCounter += simSpeed;
if ((loopCounter >= 24))
{
loopCounter = 0;
document.advanceDay();
}
}
public static function calculateDate()
{
... // sets moonCounter and yearCounter using day
date.text = document.prettyNumbers[moonCounter] + " moon of the year " + yearCounter + " B.C.";
}
document:
public static var prettyNumbers:Array = ["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth"];
...
public static function advanceDay()
{
topPanel.day++;
topPanel.calculateDate();
listPanel.sortList();
detailsPanel.refreshDetails();
}
The error returned:
Line 278 1120: Access of undefined property date.
date is the name of an instance (dynamic text field) within topPanel. The calculateDate function works perfectly when the advanceDay function is in the topPanel class and the “public static” bit is removed. Thanks for reading and I hope you can help!
The functions marked static can only access properties which are static themselves. ‘date’, I believe, isn’t a static member variable which is why the compiler is saying it can’t find a ‘date’ with necessary ‘static’ qualifier’