onClipEvent (keyDown) { // KeyEvents movieClip var key = Key.getCode(); if (key == Key.SHIFT) { key = Key.UP; _root.running = true; _root.score.text = 'Arrow keys direct shots'; } else if (_root.running == false) return; if (key == Key.SPACE) { if (_root.projectile._visible == false) { if (_root.direction != 0) { _root.projectile._x = _root.avatar._x + _root.direction * 15 - 5; _root.projectile._y = _root.avatar._y; _root.projectile.direction = _root.direction; _root.bullet.fire(_root.projectile); _root.projectile._visible = true; } } } else if (key == Key.DOWN) { _root.grid.drawGrid(_root.avatar, 4, 5, Array(0,1,1,0, 1,1,1,1, 0,1,1,0, 1,0,0,1, 1,0,0,1)); } else if (key == Key.UP) { _root.direction = 0; if (_root.avatar.x < 0) _root.avatar.x = -_root.avatar.x; _root.grid.drawGrid(_root.avatar, 4, 5, Array(0,1,1,0, 1,1,1,1, 0,1,1,0, 1,0,0,1, 1,0,0,1)); } else if (key == Key.LEFT) { _root.direction = -1; _root.grid.drawGrid(_root.avatar, 4, 5, Array(0,0,1,1, 0,0,1,1, 1,1,1,1, 0,0,1,1, 0,0,1,1)); _root.avatar._x -= 5; if (_root.avatar._x < 0) _root.clear(); } else if (key == Key.RIGHT) { _root.direction = 1; _root.grid.drawGrid(_root.avatar, 4, 5, Array(1,1,0,0, 1,1,0,0, 1,1,1,1, 1,1,0,0, 1,1,0,0)); _root.avatar._x += 5; } } onClipEvent (mouseDown) { startDrag(_root.avatar, true); } onClipEvent (mouseUp) { stopDrag(); }