What is wrong in this code? (3d)

Ok… i found the bug in the 3d pyramids routine… anyway. Do you know what is wrong here? I have points for a 3d logo at z -20 and z +20 … I am using the ifvisiblebetween function for backface culling… the problem is the program shows only the last logo (black) and not the first one (red) … if you try to delete the last one (black) from the code you’ll notice the red shows up. So why it doesn’t show up when the black is under it? I really can’t understand.


this.createEmptyMovieClip(“theScene”, 1);
theScene._x = 80;
theScene._y = 150;

focalLength = 300;
isVisibleBetween = function (a, b, c) {
if (((b.y-a.y)/(b.x-a.x)-(c.y-a.y)/(c.x-a.x)<0) ^ (a.x<=b.x == a.x>c.x)) {
return true;
} else {
return false;
}

};
make3DPoint = function(x,y,z){
var point = new Object();
point.x = x;
point.y = y;
point.z = z;
return point;
};
Transform3DPointsTo2DPoints = function(points, axisRotations){
var TransformedPointsArray = [];
var sx = Math.sin(axisRotations.x);
var cx = Math.cos(axisRotations.x);
var sy = Math.sin(axisRotations.y);
var cy = Math.cos(axisRotations.y);
var sz = Math.sin(axisRotations.z);
var cz = Math.cos(axisRotations.z);
var x,y,z, xy,xz, yx,yz, zx,zy, scaleFactor;
var i = points.length;
while (i–){
x = points*.x;
y = points*.y;
z = points*.z;
// rotation around x
xy = cxy - sxz;
xz = sxy + cxz;
// rotation around y
yz = cyxz - syx;
yx = syxz + cyx;
// rotation around z
zx = czyx - szxy;
zy = szyx + czxy;

scaleFactor = focalLength/(focalLength + yz);
x = zxscaleFactor;
y = zy
scaleFactor;
z = -yz;
TransformedPointsArray* = make3DPoint(x, y, z);
}
return TransformedPointsArray;
};
pointsArray = [
make3DPoint ( -120, -40, -20 ),
make3DPoint ( -105, -55, -20 ),
make3DPoint ( -40, -55, -20),
make3DPoint ( -165, 60, -20 ),
make3DPoint ( 170, 60, -20 ),
make3DPoint ( 170, -40, -20 ),
make3DPoint ( 130, -80, -20 ),
make3DPoint ( 45, -80, -20 ),
make3DPoint ( 20, -55, -20 ),
make3DPoint ( 110, -55, -20 ),
make3DPoint ( 135, -30, -20 ),
make3DPoint ( 135, 30, -20 ),
make3DPoint ( -90, 30, -20 ),
make3DPoint ( 30, -80, -20 ),
make3DPoint ( -150, -80, -20 ),
make3DPoint ( -120, -40, 20 ),
make3DPoint ( -105, -55, 20 ),
make3DPoint ( -40, -55, 20 ),
make3DPoint ( -165, 60, 20 ),
make3DPoint ( 170, 60, 20 ),
make3DPoint ( 170, -40, 20 ),
make3DPoint ( 130, -80, 20 ),
make3DPoint ( 45, -80, 20 ),
make3DPoint ( 20, -55, 20 ),
make3DPoint ( 110, -55, 20 ),
make3DPoint ( 135, -30, 20 ),
make3DPoint ( 135, 30, 20 ),
make3DPoint ( -90, 30, 20 ),
make3DPoint ( 30, -80, 20 ),
make3DPoint ( -150, -80, 20 ),
make3DPoint ( -120, -40, -20 ),
make3DPoint ( -105, -55, -20 ),
make3DPoint ( -40, -55, -20),
make3DPoint ( -165, 60, -20 ),
make3DPoint ( 170, 60, -20 ),
make3DPoint ( 170, -40, -20 ),
make3DPoint ( 130, -80, -20 ),
make3DPoint ( 45, -80, -20 ),
make3DPoint ( 20, -55, -20 ),
make3DPoint ( 110, -55, -20 ),
make3DPoint ( 135, -30, -20 ),
make3DPoint ( 135, 30, -20 ),
make3DPoint ( -90, 30, -20 ),
make3DPoint ( 30, -80, -20 ),
make3DPoint ( -150, -80, -20 ),
make3DPoint ( -120, -40, 20 ),
make3DPoint ( -105, -55, 20 ),
make3DPoint ( -40, -55, 20 ),
make3DPoint ( -165, 60, 20 ),
make3DPoint ( 170, 60, 20 ),
make3DPoint ( 170, -40, 20 ),
make3DPoint ( 130, -80, 20 ),
make3DPoint ( 45, -80, 20 ),
make3DPoint ( 20, -55, 20 ),
make3DPoint ( 110, -55, 20 ),
make3DPoint ( 135, -30, 20 ),
make3DPoint ( 135, 30, 20 ),
make3DPoint ( -90, 30, 20 ),
make3DPoint ( 30, -80, 20 ),
make3DPoint ( -150, -80, 20 )

];
theScene.AxisRotations = make3DPoint(0,0,0);
rotate1 = function(){
this.AxisRotations.x -= 0.0;
this.AxisRotations.y += 0.08;
this.AxisRotations.z += 0.00;
var pts2D = Transform3DPointsTo2DPoints(pointsArray, this.AxisRotations);
var mouseIsDown = Key.isDown(1);

this.clear();
if (isVisibleBetween(pts2D[3], pts2D[4], pts2D[14] )){
this.beginFill(0xFF0000, 100);
this.moveTo(pts2D[0].x, pts2D[0].y);
this.lineTo(pts2D[1].x, pts2D[1].y);
this.lineTo(pts2D[2].x, pts2D[2].y);
this.lineTo(pts2D[3].x, pts2D[3].y);
this.lineTo(pts2D[4].x, pts2D[4].y);
this.lineTo(pts2D[5].x, pts2D[5].y);
this.lineTo(pts2D[6].x, pts2D[6].y);
this.lineTo(pts2D[7].x, pts2D[7].y);
this.lineTo(pts2D[8].x, pts2D[8].y);
this.lineTo(pts2D[9].x, pts2D[9].y);
this.lineTo(pts2D[10].x, pts2D[10].y);
this.lineTo(pts2D[11].x, pts2D[11].y);
this.lineTo(pts2D[12].x, pts2D[12].y);
this.lineTo(pts2D[13].x, pts2D[13].y);
this.lineTo(pts2D[14].x, pts2D[14].y);
this.lineTo(pts2D[0].x, pts2D[0].y);
this.endFill();

}
this.clear();
if (isVisibleBetween(pts2D[48], pts2D[44], pts2D[49] )){
this.beginFill(0x000000, 100);
this.moveTo(pts2D[45].x, pts2D[45].y);
this.lineTo(pts2D[46].x, pts2D[46].y);
this.lineTo(pts2D[47].x, pts2D[47].y);
this.lineTo(pts2D[48].x, pts2D[48].y);
this.lineTo(pts2D[49].x, pts2D[49].y);
this.lineTo(pts2D[50].x, pts2D[50].y);
this.lineTo(pts2D[51].x, pts2D[51].y);
this.lineTo(pts2D[52].x, pts2D[52].y);
this.lineTo(pts2D[53].x, pts2D[53].y);
this.lineTo(pts2D[54].x, pts2D[54].y);
this.lineTo(pts2D[55].x, pts2D[55].y);
this.lineTo(pts2D[56].x, pts2D[56].y);
this.lineTo(pts2D[57].x, pts2D[57].y);
this.lineTo(pts2D[58].x, pts2D[58].y);
this.lineTo(pts2D[59].x, pts2D[59].y);
this.lineTo(pts2D[45].x, pts2D[45].y);
this.endFill();

}

};
theScene.onEnterFrame = rotate1;