PDA

View Full Version : Help with porting Java to AS3



grandpaw broon
March 5th, 2009, 06:57 AM
Hi all,

I have decided i need to convert a Java project into AS3.

On first glance, this is pretty easy but there is a couple of things i am stuck on and was wondering if anyone could help?

Well to start it all off.

The only thing i am confused about in this large class is this:


double[][] oldPositions = new double[2][10];


Later this is used like this:


for (var i:int= 0; i < 4; i++) {
oldPositions[0][i] = oldPositions[0][i+1];
oldPositions[1][i] = oldPositions[1][i+1];
}
oldPositions[0][4] = x;
oldPositions[1][4] = y;

I am not really sure what is happening here. Would anyone like to advise?

Thanks :D!

devonair
March 5th, 2009, 08:19 AM
oldPositions is just a multidimensional array:

var oldPositions:Array = [];
/* .... */
for (var i:int = 0; i < 4; i++) {
oldPositions[0][i] = oldPositions[0][i+1];
oldPositions[1][i] = oldPositions[1][i+1];
}
oldPositions[0][4] = x;
oldPositions[1][4] = y;

grandpaw broon
March 5th, 2009, 08:35 AM
oldPositions is just a multidimensional array:

ActionScript Code:

var oldPositions:Array = [];
/* .... */
for (var i:int = 0; i < 4; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;oldPositions[0][i] = oldPositions[0][i+1];
&nbsp;&nbsp;&nbsp;&nbsp;oldPositions[1][i] = oldPositions[1][i+1];
}
oldPositions[0][4] = x;
oldPositions[1][4] = y;




Ahh happy days thanks. I dare say ill be back! Though its the first time i have noticed how similar in a way it is to Actionscript.