I am using the code below to draw an object to the stage. However I want to be able to redraw the object every time I press ENTER in my onEnterframe function. So I have to add the draw function again but with a new array. Also every time I push enter the value of the variables in the array should increase.
Here's the initial code:
maat=50;
var punten:Array = new Array();
punten[0] = {x:-maat, y:-maat, z:maat};
punten[1] = {x:maat, y:-maat, z:maat};
punten[2] = {x:-maat, y:maat, z:maat};
punten[3] = {x:maat, y:maat, z:maat};
punten[4] = {x:-maat, y:-maat, z:-maat};
punten[5] = {x:maat, y:-maat, z:-maat};
punten[6] = {x:-maat, y:maat, z:-maat};
punten[7] = {x:maat, y:maat, z:-maat};
var kubusMC:MovieClip = this.createEmptyMovieClip("kubusMC", 0);
kubusMC._x = Stage.width/2;
kubusMC._y = Stage.height/2;
var kubus:Shape = new Shape(punten, kubusMC, 300, 1, 0x222222, 85);
this.onEnterFrame = function() {
if(Key.isDown(KEY.ENTER)){
}
kubus.rotateX(0);
kubus.rotateY(1);
kubus.rotateZ(0);
kubus.set2DTo3D();
}
And I want to turn it into something like this but I don't know how to exactly write this for loop for the array?!
maat=50;
var punten:Array = new Array();
punten[0] = {x:-maat, y:-maat, z:maat};
punten[1] = {x:maat, y:-maat, z:maat};
punten[2] = {x:-maat, y:maat, z:maat};
punten[3] = {x:maat, y:maat, z:maat};
punten[4] = {x:-maat, y:-maat, z:-maat};
punten[5] = {x:maat, y:-maat, z:-maat};
punten[6] = {x:-maat, y:maat, z:-maat};
punten[7] = {x:maat, y:maat, z:-maat};
var kubusMC:MovieClip = this.createEmptyMovieClip("kubusMC", 0);
kubusMC._x = Stage.width/2;
kubusMC._y = Stage.height/2;
var kubus:Shape = new Shape(punten, kubusMC, 300, 1, 0x222222, 85);
this.onEnterFrame = function() {
if(Key.isDown(KEY.ENTER)){
//the array punten contains objects with the value of maat, everytime
//enter is pushed maat has to increase by 1 and the new array needs to have
//the new value of maat
for(var i=1; i <= 100 ;i++){
maat+=i;
var "punten"+i:Array = new Array();
}
var kubus:Shape = new Shape(punten[i], kubusMC, 300, 1, 0x222222, 85);
kubus.rotateX(0);
kubus.rotateY(1);
kubus.rotateZ(0);
kubus.set2DTo3D();
}