Assigning two actions to one key + hitTest Issues

http://img225.imageshack.us/my.php?image=syncengineuw6.swf
(edit: don’t mind the target, haven’t even gotten there yet)

WASD and Space. This is going to be a rhythm-type game, where you have to hit space (fire) when the dots are aligned with the middle dot.

Hitting space not only fires a small bullet (AS placed on the grey/white outlined button on the bottom right as an on(keyPress “<Space”>)) but runs a series of hitTests to see where the dot was on the bar when you hit space (placed on the dot itself), giving you points and a ranking for how close you were to the dot. If your dot is not even on the colored bar (close to the middle dot), no points are taken.

However, a couple of odd problems have arisen. The first one is that when you start playing, the hitTests seem not to take any effect. You can hit space anywhere and the dot disappears, no ranking, no score, nothing. Even if it’s on the colored bar. Here’s the weird part. Hold space, firing off a torrent of bullets, and now you can play the game as it’s supposed to be played. I have no idea why this is happening, and this is a major issue.

Another issue is that the hitTests on the dots are a little tough to deal with… They’re working as they should, more or less, but if two of them get on the colored bar (get two on the very edges of the red), and you hit space, both of them get processed. Now, this isn’t really a flaw, it’s following the actionScript just fine-- I’m just not sure how to make it so that flash only processes the first one until it hits a certain point (past the colored bar), where it would then move on to process the next one the next time you hit space.

~~

The code for the bullets and firing is an ever-so-slightly modified version of this tutorial, just using spacebar instead of a mouse click.

The code for the dot hitTests:


if (Key.isDown(Key.SPACE)) {
        if (this.hitTest(_root.syncBar.poorLeft) or hitTest(_root.syncBar.poorRight)) {
            _root.score += 1;
            _root.rank = "Poor";
            this.removeMovieClip();
        }

The poorLeft and poorRight objects are invisible movie clips placed over the red section of the colored bar, and this code pretty much just repeats with different instance names and variable defs.

.fla in attached zip.