0

我有四个类:documenttopPanellistPaneldetailsPanel。在此特定示例中,topPanel检查何时提前一天(文档中的一个函数)。当AdvanceDay被激活时,文档告诉topPanelcalculateDatelistPanelsortListdetailsPanelrefreshDetails计算日期然后计算出日期并尝试更新动态文本字段但找不到它的实例。sortListrefreshDetails也会出现类似的问题。

顶部面板:

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函数可以完美运行。感谢阅读,希望对您有所帮助!

4

1 回答 1

0

标记为静态的函数只能访问本身为静态的属性。我相信“日期”不是静态成员变量,这就是为什么编译器说它找不到具有必要“静态”限定符的“日期”

于 2013-02-03T08:41:41.750 回答