2013-01-21 42 views
0

我正在與Flash AS3 GUI應用程序,我得到這個錯誤:
類型錯誤:錯誤#2007:參數文字必須是非空的錯誤在AS3

Attemping to launch and connect to Player using URL C:\B Services\Divatri\Appy\appy.swf 
[SWF] C:\B Services\Divatri\Appy\appy.swf - 32351 bytes after decompression 
TypeError: Error #2007: Parameter text must be non-null. 
at flash.text::TextField/set text() 
at appy_fla::MainTimeline/ParseUsers()[appy_fla.MainTimeline::frame101:44] 
at appy_fla::MainTimeline/LoadXML()[appy_fla.MainTimeline::frame101:17] 
at flash.events::EventDispatcher/dispatchEventFunction() 
at flash.events::EventDispatcher/dispatchEvent() 
at flash.net::URLLoader/onComplete() 
Cannot display source code at this location. 
Debug session terminated. 

這是我的AS3: http://pastebin.com/QBGamWkJ
任何幫助將不勝感激

回答

1

AS3(和大多數其他地方)的數組和XMLLists是從零開始的。所以,你想:

if (usercount == 1) 
{ 
    user1.username_txt.text = usernames[0]; // not usernames[1] 
    ... 

你可能會考慮具有user秒的陣列,而不是通過user6明確列出user1。如果您堅持使用您當前的結構,請考慮將它們重命名爲基於零的名稱以匹配您的XMLList。

+0

好吧。我會試試看。 – user1910744

+0

TAHNK你SOOOOO很多! – user1910744

0

數組的索引爲零(0)。所以你陣列中的第一個用戶實際上是0而不是1。該錯誤告訴您,您嘗試訪問的項目爲空,因爲usernames[2]不存在於長度爲2的數組中。

您的代碼應該是這樣的:

if (usercount == 2) { 
    user1.username_txt.text = usernames[0]; 
    user2.username_txt.text = usernames[1]; 
    ... 
} 
相關問題