1

I'm trying to create 2d array however I'm getting error. Here's my code:

var cleanArr:Array = new Array();
for (var i:int = 0; i < arr.length; i++)
{
    cleanArr[i][0] = arr[i].substring(0, 29);
    cleanArr[i][1] = arr[i].substring(29, int.MAX_VALUE);

    trace(cleanArr[i]);
}

I get this error:

TypeError: Error #1010: A term is undefined and has no properties.

at SubtitleLoader/onComplete()[C:\Users\ ... \SubtitleLoader.as:88]

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at flash.net::URLLoader/onComplete()

Line 88: cleanArr[i][0] = arr[i].substring(0, 29);

How can I fix this?

1 Answer 1

2

cleanArr is completely empty, it isn't a 2D array. For it to be a 2D Array, the items in it have to be Arrays. In Your code they do not exist at all. You have to create an array at the given position first. Try this:

var cleanArr:Array = new Array();
for (var i:int = 0; i < arr.length; i++)
{
    cleanArr[i] = new Array();
    cleanArr[i][0] = arr[i].substring(0, 29);
    cleanArr[i][1] = arr[i].substring(29, int.MAX_VALUE);

    trace(cleanArr[i]);
}
Sign up to request clarification or add additional context in comments.

Comments

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.