0

I have a class consisting of a nested array called twoDArray.

  public class TestArray 
  {

  public function TestArray() {

  var twoDArray:Array = new Array(new Array("one","two"), new Array("three", "four"));
  } 

  }

I have another class which attempts to make a variable of type TestArray.

  var OrbArray:TestArray = new TestArray();

I thought I would be able to reference OrbArray for example using trace(OrbArray[0][0]); giving me the output I am looking for of "one". When I attempt this I get ReferenceError: Error #1069: Property 0 not found on com.orbclasses.TestArray and there is no default value. Help most appreciated.

2 Answers 2

1
public dynamic class TestArray extends Array
{

  public function TestArray()
  {
    push(new Array("one", "two"), new Array("three", "four"));
  }
}
Sign up to request clarification or add additional context in comments.

Comments

0

In your TestArray class:

public class TestArray
{
  public var twoDArray:Array = null;

  public function TestArray()
  {
    twoDArray = new Array(new Array("one", "two"), new Array("three", "four"));
  }
}

Note: twoDArray is publicly accessible.

Now when you want to access it:

var testArray:TestArray = new TestArray();
trace("output:", testArray.twoDArray[0][0]);

i.e. you try to access the property twoDArray which belongs to testArray.

If you want to do testArray[0][0] for some reason, you can do that too, but for that you'll have to look at the flash.utils.Proxy class.

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.