Actionscript 3 拼接函数在数组中添加额外的元素
当我使用拼接函数时,它插入点,但复制阵列最后一个元素的副本Actionscript 3 拼接函数在数组中添加额外的元素,actionscript-3,apache-flex,flex3,Actionscript 3,Apache Flex,Flex3,当我使用拼接函数时,它插入点,但复制阵列最后一个元素的副本 for(indexpoint=0;indexpoint<intpoints.length;indexpoint++) { temp.points[indexpoint].x = intpoints[indexpoint].x+this.x; temp.points[indexpoint].y = intpoints[indexpoint].y+this.y;
for(indexpoint=0;indexpoint<intpoints.length;indexpoint++)
{
temp.points[indexpoint].x = intpoints[indexpoint].x+this.x;
temp.points[indexpoint].y = intpoints[indexpoint].y+this.y;
}
const point:Point = new Point();
point.x = (intpoints[2].x+intpoints[3].x)/2+this.x;
point.y = (intpoints[2].y+intpoints[3].y)/2+this.y;
temp.points.splice(3,0, point);
for(indexpoint=0;indexpoint)不应该发生这种情况
我试过这个:
var a:Array = new Array(new Point(0,0), new Point(0, 1), new Point(0, 2));
var p:Point = new Point(0, 3);
a.splice(3, 0, p);
trace(a);
这可以正确地跟踪:(x=0,y=0),(x=0,y=1),(x=0,y=2),(x=0,y=3)
在调用接头之前,可以尝试跟踪temp.points数组吗