user2120268
user2120268

Reputation: 3

value in array concatenation with string not working

In the following code, I want to concatenate the data in array arr1 with string value in variable t.

var t:String;
var arr4:Array = new Array();
for(w;w<i;w++){
    if(max==arr3[w]){
    t=t.concat(",",arr1[w])
    }
}
trace(t);

But I get this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at final1_fla::MainTimeline/modebtn()

Can anyone help me?

Upvotes: 0

Views: 183

Answers (1)

Barış Uşaklı
Barış Uşaklı

Reputation: 13532

That code doesn't make sense at all, arr4 is initialized but never used, instead arr3 and arr1 is used which might not be initialized and causing the null object reference error.

Your loop is using w which is not initialized and is comparing against i which isn't shown here.

Make sure your arrays are valid and check if that for loop is functioning as you expect it to.

Upvotes: 2

Related Questions