this.attachMovie Problem
I guys i am not new to game desigining in flash as2 but i am a little rusty at the moment. I am trying to create a block breaking game and have done well so far as making the blocks, ball/walls and paddle but now i am trying to add the power ups. I cant get the this.attachMovie to work, its works as so, there is a random number generator and it generates every time a block is broken once the number is higher than 90 it activates the code. Can somebody please tell me what i am doing wrong here, heres my code:
function makeLvl():Void{
var arrayLength:Number = _root.lvlArray[currentLvl-1].length;
var brickRow:Number = 0;
for(var i:Number = 0;i<arrayLength;i++){
if(lvlArray[currentLvl-1][i] == 1){
_root.brickAmt ++;
_root.attachMovie('mcBrick', 'brick'+i,_root.getNextHighestDepth(),{_x:9999, _y:9999});
_root['brick'+i]._x = 15+(i-brickRow*10)*75;
_root['brick'+i]._y = 10+brickRow*20;
_root['brick'+i].onEnterFrame = function(){
if(this.hitTest(_root.mcBall)){
displayRandomNumber();
this.removeMovieClip();
ballYSpeed *= -1;
_root.brickAmt --;
if(randomNumberText.text>=90){
this.attachMovie('mcBg', 'doubleball',_root.getNextHighestDepth());
trace("doubleball");
}
}
if(_root.gameOver){
this.removeMovieClip();
}
}
for(var c:Number = 1;c<=10;c++){
if(i == c*10-1){
brickRow ++;
}
}
}
}
}
|