1. Computing

Custom Christmas Tree Ornaments that Move with Drag & Drop or Arrow Keypresses

By

1 of 9

Introduction; Key.isDown (ActionScript 2.0)
Custom Christmas Tree Ornaments that Move with Drag & Drop or Arrow Keypresses
This lesson is similar to the series of lessons on creating a snowman with drag-and-drop parts that you could add and remove at will (and in fact, that’s where I snitched the trees from, while the falling snow came from another lesson). However, this time we’ll add new depth to the level of interactivity; not only will users be able to click and drag on ornaments to decorate the tree with their mouse, they’ll also be able to guide selected ornaments using the arrow keys on a standard keyboard in order to nudge them into just the right spot.

We’ll use something new for this: Key.isDown, a function that checks to see if a key is pressed. When used in tandem with an if statement and other Key.parameter functions, it can be used to determine motion based on keypresses.

©2014 About.com. All rights reserved.