0

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?

1
  • Is StackOverflow a modern version of Rubber Duck Debugging? Commented Mar 6, 2013 at 18:29

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

sorry about that. arr3,arr1,w,i initialized in top in my original coding. but i only paste this concatenate part only. is this concatenate code OK
if arr3 and arr1 are valid arrays and if w isn't going out of bounds it is, Cannot access a property or method of a null object reference means something isn't initialized but it is being accessed. Debug and see the value of w and what it is accesing in those arrays.
I use trace(arr1[w]); in that place and I got my output. i want to take this output in one sting. if(max==arr3[w]){ trace(arr1[w]); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.