Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 TypeError:Error#2007:参数文本在as3中必须为非空错误_Actionscript 3_Flash - Fatal编程技术网

Actionscript 3 TypeError:Error#2007:参数文本在as3中必须为非空错误

Actionscript 3 TypeError:Error#2007:参数文本在as3中必须为非空错误,actionscript-3,flash,Actionscript 3,Flash,我正在用Flash AS3制作一个GUI应用程序,我遇到了以下错误: 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-

我正在用Flash AS3制作一个GUI应用程序,我遇到了以下错误:

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:

任何帮助都将不胜感激。

AS3(以及大多数其他地方)中的数组和XMLList是基于零的。所以你想要:

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

您可以考虑使用<代码>用户 s数组,而不是通过<代码> USE6显式列出<代码> USER1<代码>。如果你坚持你当前的结构,考虑将它们重命名为零的名称以匹配XMLList.< /P>

数组为零(0)索引。因此,数组中的第一个用户实际上是

0
,而不是
1
。错误告诉您,您试图访问的项目为空,因为长度为
2
的数组中不存在
用户名[2]

您的代码应该如下所示:

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