How can I create an Adobe Flash Starfield which changes based on user control?

I would like to create a star field in Adobe flash that dynamically changes based on user arrow key controls. Basically, the effect I want is that a user looks like they are inside the cockpit of a ship, and when they move the arrow keys, they are “flying” through space, and every once in a while space images will appear so that it gives the space traveler effect. Could someone point me in the right direction? Thanks!

Answer
? Favorite Answer

  • If you are looking for some kind of D animation then the following is not what you are looking for, but give it a go anyway! xD

    *Make sure the cockpit image is on one layer, and the starfield image is on another layer, below the first.

    *Enlarge the starfield image so that it is larger than the cockpit (Shortcut: Q).

    *Select the starfield image and convert it to a movieclip (Shortcut: F).

    *Select the starfield image if it isn’t already then open the Actions panel (Shortcut: F) and enter the following code.

    onClipEvent (enterFrame) {

    if (Key.isDown(Key.RIGHT)) {

    this._x -= ;

    }

    if (Key.isDown(Key.LEFT)) {

    this._x += ;

    }

    if (Key.isDown(Key.UP)) {

    this._y += ;

    }

    if (Key.isDown(Key.DOWN)) {

    this._y -= ;

    }

    }

    I have reversed the x and y values to make it look as if you are controlling the ship and not the starfield itself.

    If you want to experiment with this, try changing the x’s and y’s, the -‘s and +’s, and the ‘s.

    Good luck!

  • Leave a Comment