我有四个类:document、topPanel、listPanel和detailsPanel。在此特定示例中,topPanel检查何时提前一天(文档中的一个函数)。当AdvanceDay被激活时,文档告诉topPanel去calculateDate,listPanel去sortList和detailsPanel去refreshDetails。计算日期然后计算出日期并尝试更新动态文本字段但找不到它的实例。sortList和refreshDetails也会出现类似的问题。
顶部面板:
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.";
}
文档:
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();
}
返回的错误:
Line 278 1120: Access of undefined property date.
date是 topPanel 中实例(动态文本字段)的名称。当AdvanceDay函数位于topPanel类中并且“公共静态”位被删除时, calculateDate函数可以完美运行。感谢阅读,希望对您有所帮助!