2013-01-21 37 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]; 
    ... 
} 
相关问题