0
votes

I'm making a GUI application with Flash AS3 and I'm getting this error:

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.

And here's my AS3: http://pastebin.com/QBGamWkJ
Any help will be appreciated

2

2 Answers

1
votes

Arrays and XMLLists in AS3 (and in most other places) are zero-based. So you want:

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

You might consider having an array of users, rather than explicitly listing user1 through user6. If you stick with your current structure, consider renaming them to zero-based names to match your XMLList.

0
votes

Arrays are zero(0) indexed. So your first user in the array would actually be 0 rather than 1. The error is telling you that the item you are attempting to access is null because usernames[2] does not exist in an array with a length of 2.

Your code should look like:

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