Solved

Looping thru 2 dim array

Posted on 2012-08-23
571 Views
Hi experts:
I have an array in Actionscript 3.

private var myArray:Array = [  [1.2,3.4],
[7.8,10.4],
[12.2,1.0]];

I would like to be able to get the first element, the point 1.2, 3.4, in a loop.  When I try this I get a large error.

I would like to do this:
for (var i:uint; i < myArray.length; i++) {
point = myArray[i,0];
point2 = myArray[i,1];

etc.
}

Thoughts?
0
Question by:snix123

LVL 44

Accepted Solution

I'm not sure of the exact syntax, but I think you're going to have to use an intermediate array to get at the data in the manner your code snippet suggests.
Example:
private var myPoint;

for (var i:uint; i < myArray.length; i++) {
myPoint = myArray[i];
point = myPoint[0];
point2 = myPoint[1];

etc.
}

0

Author Closing Comment

Thank you...
0

Featured Post

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…