So I've had a look around on the problems and cant find the solution to my action script problems

Firstly, I want to be able to push the space bar on my keyboard during a swf, and for a movie clip to appear on the stage. This is what i have so far:

Code:
onClipEvent(enterFrame){
		
	if(Key.isDown(Key.SPACE)){
			_root.attachMovie("Explosion", "Explosion"+i, _root.getNextHighestDepth());
			_root["Explosion"+i]._x = _x;
			_root["Explosion"+i]._y = _y-20;
	}
}
I dnt know whats wrong, but its not working....

Secondly, I want A movie clip to spawn in the middle of the stage, then randomly travel outwards to the edge of the stage, then dissapear. And this needs to happen over and over, with the same movie clip travelling to a different place each time. This is what i have so far :

Code:
onClipEvent(load){
	timer = 0;
	i = 0;
	a = 0;
	b = 0;
}
 
onClipEvent(enterFrame){
	if(timer > 0){
		timer --;
		a = Math.round(Math.random()*20);
		b = Math.round(Math.random()*20);		
	}
 
		if(timer == 0){
			_root.attachMovie("RockSmall2Big", "RockSmall2Big"+i, _root.getNextHighestDepth());
			_root["RockSmall2Big"+i]._x = 275;
			_root["RockSmall2Big"+i]._y = 200;
			_root["RockSmall2Big"+i]._width = Math.round(Math.round()*
 
			_root["RockSmall2Big"+i].onEnterFrame = function(){
				this._y -= a;
				this._x -= b;
				if(this._y < -30){
					this.removeMovieClip();
				}
			}
 
			i ++;
			timer = 20;
	}
}

Please help