I am working with the 3D engine in one of the tutorials, but I am expanding one of the functions to have an Array with objects as a parameter:
backAndForthAndSideToSide = function (pointsArray:Array) {
var screenPoints = new Array();
for (var i = 0; i<pointsArray.length; i++) {
var thisPoint = pointsArray*;
if (direction == "left") {
thisPoint.y -= speed;
if (i == pointsArray.length-1 && thisPoint.y<=-150) {
direction = "backward";
}
} else if (direction == "backward") {
thisPoint.z += speed;
if (i == pointsArray.length-1 && thisPoint.z>=150) {
direction = "right";
}
} else if (direction == "right") {
thisPoint.y += speed;
if (i == pointsArray.length-1 && thisPoint.y>=150) {
direction = "forward";
}
} else if (direction == "forward") {
thisPoint.z -= speed;
if (i == pointsArray.length-1 && thisPoint.z<=-150) {
direction = "left";
}
}
With the array:
MakeA3DPoint = function (x, y, z) {
var point = new Object();
point.x = x;
point.y = y;
point.z = z;
return point;
};
MakeBox = function (Num, Width, Depth, Height) {
_root.createEmptyMovieClip("box"+Num,Num);
Points = new Array();
Points = [[-Width/2, -Height/2, -Depth/2], [Width/2, -Height/2, -Depth/2], [Width/2, -Height/2, Depth/2], [-Width/2, -Height/2, Depth/2], [-Width/2, Height/2, -Depth/2], [Width/2, Height/2, -Depth/2], [Width/2, Height/2, Depth/2], [-Width/2, Height/2, Depth/2]];
for (i=0; i<Points.length; i++) {
Points* = MakeA3DPoint(Points*[0], Points*[1], Points*[2]);
}
return Points;
};
this.pointsArray2 = _root.MakeBox(2,80, 80, 80);
box.onEnterFrame = backAndForthAndSideToSide(pointsArray2);
Thank you to any insight you can provide,