More than one key at once

i know ive seen sample fla’s on here using this… but i cant seem to find one… so ill just post again…

im makin a space ship game… and i want to be able to move my plane and fire the lasers at the same time… but the way im doing it… flash is only allowing me to press one key at a time… i know there is a function like getKey.whatever or somthin… but that makes it continuously move one direction even if i let off the key… so i changed it… i tried to make it move with easing… that didnt work as well… its sort of a mess…

basically i have an extra button on the side of the stage to hold the code for pressing keys… since i dont know how to do it within movie clips… so in the button i have:


on(keyPress"<left>"){
	_root.targx -= 10;
}
on(keyPress"<right>"){
	_root.targx += 10;
}
on(keyPress"<up>"){
	_root.targy -= 10;
}
on(keyPress"<down>"){
	_root.targy += 10;
}
on(keyPress"<space>"){
	i++;
	if(i==20){
		i=10;//limit on lasers on the stage
	}
	shoot(i);
}

targx and targy are declared in the first frame of the main timeline so they can be initalized… and i attempted to make a function to move the ship… so in the frame the prototype is:


MovieClip.prototype.move = function (endx, endy, speed) {
	this._x += (endx-this._x)/speed;
	this._y += (endx-this._y)/speed;
};

and in the movie clip i have:


onClipEvent(enterFrame){
	moveX = _root.targx;
	moveY = _root.targy;
	move(moveX, moveY, 5);
}

im expiramenting with new ways of doin stuff… i know functions and prototypes are good… but im still learnin how to use them… anyway… also my lasers work… but… with the limit of 10 on the levels it takes up… if i hold down the space bar they shoot so fast that they overlap… i know 10 lasers should be able to go across the screen… but they overlap and dont… is there a way to delay them so not so many are on the stage at once if i hold the button down?

i hope i explained all that stuff clear…

thanks in advance to anyone who helps me out…

oh yeah, just in case you wonder what

shoot(i);

does… it just calls a prototyped function that duplicates the laser… haha i actually got that one to work!

ok… sorry for having made you read all that… i got the movement/lasers… i found a post by bauermeister about jumping… i found the multpile keys at once thing… so anyway… now its just a matter of collision detection between all the duplicated enemies/lasers… which im not sure how to check an enemy/laser that is duplicated… what would the name be?

what i tried was…within the movie clip i put:


	enemyToCheck=["enemy1"+i];
	for(i=40; i<=60; i++){
		if(this, hitTest(enemyToCheck)){
			this.removeMovieClip();
		}
	}

40 - 60 are… theoretically… the levels that i assign to the enemies as they are generated if i am right… the generation code is:


	if(create1 < .2){//20% chance 
		j++;
		_root.enemy1.duplicateMovieClip("enemy1"+j, j);
		if(j == 60){//only allows 20 enemies on the screen at once
			j=40;
		}
	}

create1 is just a variable that is assigned Math.random();

so anyway… now you see what i have tried… what am i doing wrong for the collison?

umm haha seems i am smarter than i think… i think… :q:

anyway… i looked at flashkit (yes im sorry… i trusted a site other than kirupa)… but anyway… in their game tutorial i saw that i was putting a . in when i didnt need it… i was putting _root.[“enemy1”+i] instead of just _root[“enemy1”+i]… so now all is well…

sarcastically
WOW THANKS ALOT FOR YOUR HELP! YOU GUYS ARE SO FAST!

haha j/k…

while you are here though… i would like to put a small delay between shots fired… as to not make the game too easy by just holding down the space bar and moving up and down…

does it seem like im talking to myself here? lol… not really a question… but for some reason also my game is running extremely slow… all i have is the ship, 1 enemy ship, and a laser… i dont know why it is going so extremely slow… nothing else is running that slow… any ideas?